c# - Getting information on current property via Reflection inside attribute -


i'm creating custom attribute in c#.

so have this:

[attributeusage(attributetargets.property)] public class : attribute {    public    {        assembly = assembly.getcallingassembly();    } } 

the code above give me assembly name of assembly attribute being called from.

what know if there way name , type of property attribute added. example if had:

// should return system.int32 , mystring [something] public int myint {get; set;}  // should return me system.string, , mystring [something] public string mystring {get; set;} 

is there way values upon adding attribute, or have resort looping trough properties in type , see ones have attribute assigned them?

thanks in advance.

there no other way iterating on properties , check attributes. should able in 1 linq statement.

use getcustomattributes on getproperties method of types.

you optimize performance, if mark classes use attributes marked interface, common base class or class attribute. prefetch classes instead iterate on types.


Comments