Created
March 28, 2013 13:55
-
-
Save aloon/5263296 to your computer and use it in GitHub Desktop.
Get the additional info inserted in property through attributtes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Reflection; | |
class moreInfoAttribute : Attribute | |
{ | |
public string valor { get; set; } | |
} | |
public class MyClass | |
{ | |
[moreInfoAttribute(valor = "vale masInfo")] | |
public bool MyProp { get; set; } | |
} | |
class GetInfoAttribute | |
{ | |
static void Main(string[] args) | |
{ | |
string e = (typeof(MyClass).GetProperty("MyProp").GetCustomAttribute(typeof(moreInfoAttribute)) as moreInfoAttribute).valor; | |
Console.WriteLine(e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
documentation codeproject based