I have a class decorated with a attribute ...[DataEntity(\"MESSAGE_STAGING\", EnableCaching = true, CacheTimeout = 43200)]
for some requirement,I want t
If i understand you correctly, there is a possible way in reflection to change the attribute value of a instance at runtime.. checkout the sample code
AttributeCollection ac = TypeDescriptor.GetAttributes(yourObj);
foreach (var att in ac)
{
//DataEntityAttribute -- ur attribute class name
DataEntityAttribute da = att as DataEntityAttribute ;
Console.WriteLine(da.field1); //initially it shows MESSAGE_STAGING
da.field1= "Test_Message_Staging";
}
//Check the changed value
AttributeCollection acc = TypeDescriptor.GetAttributes(yourObj);
foreach (var att in ac)
{
DataEntityAttribute da = att as DataEntityAttribute ;
Console.WriteLine(da.field1); //now it shows Test_Message_Staging
}