custom attribute question
-
Is it possible to define an attribute that describes a property of a class at runtime? For example, you have a class called "employee", and it has a property "name". The "name" property has an attribute that tells any calling code whether or not this property is "writable" and/or "readable", even though this property has both get/set accessors. Maybe there is another way to do this, and I just don't have enough experience. Any help is appreciated.
-
Is it possible to define an attribute that describes a property of a class at runtime? For example, you have a class called "employee", and it has a property "name". The "name" property has an attribute that tells any calling code whether or not this property is "writable" and/or "readable", even though this property has both get/set accessors. Maybe there is another way to do this, and I just don't have enough experience. Any help is appreciated.
For what you are trying to do, I suggest that you should try to avoid using attributes
-
For what you are trying to do, I suggest that you should try to avoid using attributes
Is there a way to set a property of a property, at runtime, then? This is what I REALLY want to do, but I believe this is not possible:
[AttributeUsage(AttributeTarget.Property,Inherited=true,AllowMultiple=true)] public class SecurityInfoAttribute : Attribute { // Private Data private int readable; private int writable; // Constructor public SecurityInfoAttribute(int readable, int writable) { this.security_readable = 0; this.security_writable = 0; } public int Readable { get { return readable; } set { readable = value; } } public int Writable { get { return writable; } set { writable = value; } } } public class employee { string name; [SecurityInfo(getReadSecurityInfo(userId), getWriteSecurityInfo(userId))] string Name{get{return name;}set{name = value;}} }