mardi 31 mars 2015

Issue finding custom attributes

I am trying to find all the methods in my assembly that have a custom attribute. I have tried the other solutions posted on here, but I cant seem to get any results on which methods have the attribute type I am looking for. Hopefully someone can point out what I am doing wrong.



[AttributeUsage(AttributeTargets.All)]
public class RPCAttributeType : Attribute
{
private string _name;
private double _version;

public double Version
{
get { return _version; }
set { _version = value; }
}

public string Name
{
get { return _name; }
set { _name = value; }
}

public RPCAttributeType(string name)
{
Name = name;
Version = 1.0;
}
}


public RPCModule()
{
try
{



Assembly assembly = Assembly.ReflectionOnlyLoad("Parser");


var results = CustomAttributeData.GetCustomAttributes(assembly);

ShowAttributeData(results);


}
catch(Exception ex)
{
Console.WriteLine(ex.Message);

}

}

[RPCAttributeType("Select")]
public DataRow[] Select(string expression)
{
return MessageDataTable.Select(expression);
}





Aucun commentaire:

Enregistrer un commentaire