I have a dictionary that is of type Dictionary [string, handler_func] where
handler_func is a delegate of type
public delegate void HANDLER_FUNC(object obj, TcpClient client);
I now have an attribute class similar to
[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 main idea is that I apply this attribute to a method in the class, and somewhere I use reflection to populate the Dictionary above
The problem is that if this method is not static, then the atrribute attribute does not work therefore
[MessageHandlerAttribute("HandleLoginResponse",HandleLoginResponse)]
private void HandleLoginResponse(object obj, TcpClient client)
causes a standard need for an object thing
So what are my parameters (I don't want the handler method to be static) Thanks
source
share