Groups | Blog | Home
all groups > dotnet clr > march 2007 >

dotnet clr : Howto: Determine within a custom attribute, the type it has been declared on?


Kenneth Baltrinic
3/16/2007 1:36:59 AM
I have a custom attribute that inherits from System.Attribute and itself is
declared with the AttributeUsage( AttributeTargets.Class ) attribute.
Regarding this I have two questions.

Can I further limit my attribute to only be applicable to types that are
concrete and have a public default constructor?
Can I, from within my attribute class determine the System.Type of the class
to which it has been applied?

--Ken

Ben Voigt
3/16/2007 2:18:03 PM

[quoted text, click to view]

An attribute can accept a Type parameter to its constructor, but the caller
would have to manually specify the class it is being applied to.

[quoted text, click to view]

Oliver Sturm
3/16/2007 5:55:10 PM
Hello Kenneth,

[quoted text, click to view]

I don't think either of these is possible.


Oliver Sturm
--
AddThis Social Bookmark Button