I have a dictionary which is of type
Dictionary [string,handler_func]
where
handler_func is a delegate of type
public delegate void HANDLER_FUNC(object obj, TcpClient client);
now I have an attribute class like so
[AttributeUsage(AttributeTargets.Method)]
public class MessageHandlerAttribute : Attribute
{
public MessageHandlerAttribute(string s1, HANDLER_FUNC hf)
{
s1 = name;
msgtype = hf;
}
private string name;
public string HandlerName
{
get { return name; }
set { name = value; }
}
private HANDLER_FUNC msgtype;
public HANDLER_FUNC MessageName
{
get { return msgtype; }
set { msgtype = value; }
}
}
The basic idea is I apply this attribute to a method in a class and somewhere I use reflection to fill up the Dictionary above
problem is unless this method is static the atrribute is not working so
[MessageHandlerAttribute("HandleLoginResponse",HandleLoginResponse)]
private void HandleLoginResponse(object obj, TcpClient client)
is causing the standard need an object thing
So what are my options ( i do not want the handler method to be static )
Thanks