Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 36,497 times

Contents

Related Categories

Attributed Programming in .NET Using C# - Under the hood

ddutta

Under the hood

What does exactly happen to our custom attribute when the compiler compiles the class User? The simple explanation goes like this: when the compiler encounters the ValidLength specification in class User, it looks for a class ValidLength but it can find one. It then searches for a class ValidLengthAttribute and it finds one. Next, the compiler verifies if the target of ValidLengthAttribute is valid. It then verifies if there is a constructor whose signature matches the parameters used in the attribute specification. If a named parameter is used, it also verifies the existence of field or property by that name. The compiler also verifies if it is able to create an object of ValidLengthAttribute class. If no error is encountered, the attribute parameter values are stored along with other metadata information of the class.

Comments

  • Why attribute

    Posted by soruabhm on 03 May 2004

    Hi
    Good article.I have a qus here. I have used a ot of attributes and have tried writing mine as well. Now the basic qus of when to write one of our own is still a little difficult for me. I understa...

  • Serialization SOAP

    Posted by zaka48 on 06 Mar 2004

    how can I Add a reference to assembly System.Runtime.Serialization.Formatters.Soap.dll ???

  • Private attributes in .Net c#?

    Posted by nguyen422 on 10 Jan 2003

    This is a very good article.

    The example shown used public modifier for the class attributes, is there any way to get it to work with private/protected attributes? I tried the example code usin...

  • Attributes

    Posted by chinnu704 on 06 Jan 2003

    I have absolutely no knowledge of C# and attributes, but I could understand the article very easily. Good Write-up!

  • Drawbacks of attributed programming

    Posted by ghanshyam on 12 Nov 2002

    Well the attributed programming started from MIDL/COM programming and .NET also supports this concept widely.
    The advantages provided with attributed programming is amazing and simultaneously it has ...