Related questions
Custom attribute on property - Getting type and value of attributed property
I have the following custom attribute, which can be applied on properties:
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
public class IdentifierAttribute : Attribute
{
}
For example:
public class MyClass
{
[Identifier()]
public string Name { get; set; }
public int SomeNumber { get; set; }
public string SomeOtherProperty { …
How to get a custom attribute from object instance in C#
Let's say I have a class called Test with one property called Title with a custom attribute:
public class Test
{
[DatabaseField("title")]
public string Title { get; set; }
}
And an extension method called DbField. I am wondering if getting a custom …
How to get Custom Attribute values for enums?
I have an enum where each member has a custom attribute applied to it. How can I retrieve the value stored in each attribute?
Right now I do this:
var attributes = typeof ( EffectType ).GetCustomAttributes ( false );
foreach ( object attribute in attributes )
{
…