dimanche 1 novembre 2015

Invoking customized attributes by reflection

I want to understand the usag of Attributed programming so i made a class which has been inherited from System.Attribute.

class CustomizedAttr:System.Attribute
    {
        private string msg = "Attr";

        public string Msg
        {
            get { return msg; }
        }
    }

I have placed it at the top of another class to add more meta to the class.

[CustomizedAttr]
class Test
{
    public Test()
    {

    }
}

I know how to use reflection concepts although i have never used them to get customized attributes in my applications. Now what should i do if i want to show these extra (meta data)s using reflection ?

Type t = typeof (Test);
// waht is the next step ? 





Aucun commentaire:

Enregistrer un commentaire