473,569 Members | 3,043 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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++ )
{
MetadataAttribu te[] attribs =
(MetadataAttrib ute[]fieldInfo[i].GetCustomAttri butes(
typeof(Metadata Attribute), false );
for ( int x = 0; x < attribs.Length; x++ )
{
Console.WriteLi ne( 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 1195

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

Similar topics

9
1850
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" element.onfocus = function() {FocusIsOn = "Button_1"; alert(FocusIsOn)} That works great. If the button gets the focus, I got a message box saying...
8
5014
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 assembly in "C:\Program Files\Microsoft Visual Studio ..NET 2003\Common7\IDE": shoudn't it be the application's directory instead? 2) I'm unable to...
0
1608
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 add code "" in file AssemblyInfo.cs. But it seemed that it didn't work. I don't know why. CODE AS BELOW:
3
3743
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 class. If is attached I want to perform some action. How can I access custom attributes from an HttpModule? I have to pass a target to the...
3
3526
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 changed value of that custom attribute is not reflecting back at server side. Any ideas about this problem? Server side code: private void...
2
3517
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, not assembly usage. Assembly attribute 'System.Runtime.InteropServices.GuidAttribute' is not valid: Assembly custom attribute...
1
2442
by: bg | last post by:
hi all, I have this: // custom attribute internal class ThingAttribute : System.Attribute { ... } enum LotsOfThing
2
2514
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 is the usage of "Custom Attribute" in real life project. Can somebody please help me understand where are these informations really helpful in...
6
4794
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 install the dll to the same directory as the exe which uses it, everything works as expected but if I load the dll in any other directory, I get the...
0
7619
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7930
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7681
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6290
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3662
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2118
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1229
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.