473,387 Members | 1,283 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Modifying value of custom attribute at runtime

I have a custom attribute with an "IsPresent" property with get; set
accessors.
When the attribute is applied to a field of a class, IsPresent will be false
by default.
At runtime, I'll read in the custom attributes of every field in the class,
and would like
to set IsPresent to false if certain application conditions are met,
something like so:

static void ReadHeader( ref MusicHeaderInfo info )
{
FieldInfo[] fi = (FieldInfo[])info.GetType().GetFields();
for ( int i = 0; i < fi.Length; i++ )
{
MetadataAttribute[] attribs =
(MetadataAttribute[]fieldInfo[i].GetCustomAttributes(
typeof(MetadataAttribute), false );
for ( int x = 0; x < attribs.Length; x++ )
{
Console.WriteLine( attribs[x].IsPresent ); // output is false
attribs[x].IsPresent = true; // change to true for testing
}
}
}
For testing:

MusicHeaderInfo info = new MusicHeaderInfo();
ReadHeader( ref info );
ReadHeader( ref info );

The output is always false. So even though I could change the value of the
attribute at runtime,
the changes didn't stick.

Any ideas?
Ron
Nov 17 '05 #1
0 1179

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Stefan Mueller | last post by:
I'd like to set a variable called 'FocusIsOn' if a button got the focus. Because my button is dynamically created I do it like xelement = document.createElement("input") xelement.type = "button"...
8
by: Martin Lapierre | last post by:
I try to make a custom CodeAccessSecurityAttribute, but hit the wall at every corner. I created a simple custom security attribute, which is working (see below). But... 1) I have to put the...
0
by: Erick Shuai | last post by:
In my project, I need to use custom attribute on all assemblies. This attribute will implement some non-functional code and I want to use it on assembly scope(AttributeTargets is Assembly). I...
3
by: Michael Iantosca | last post by:
I have a custom attribute that I attach to certain pages in my application and I want to inspect each page request as it is made to see if the custom attribute is attached to the underlying page...
3
by: The Developer | last post by:
Hi All, I have a web application where I am adding a custom attribute to my ASP.NET text box control and changing value of that attribute at client side using JavaScript. My problem is that...
2
by: Harry F. Harrison | last post by:
I get 2 compile errors on assembly attributes after creating a custom attribute. If I comment out the attribute, the errors go away. I don't get it because my attribute specifies class usage,...
1
by: bg | last post by:
hi all, I have this: // custom attribute internal class ThingAttribute : System.Attribute { ... } enum LotsOfThing
2
by: prabhupr | last post by:
Hi Folks I was reading this article (http://www.dotnetbips.com/articles/displayarticle.aspx?id=32) on "Custom Attribute", written by Bipin. The only thing I did not understand in this article...
6
by: Jeff Hegedus | last post by:
I have a dll that requires some configuration data. I put the configuration data in a custom configuration section in a config file that is loaded in the installation folder of the dll. If I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.