public MsgManager() { Message msg = new Message(); Type type = typeof(Message);//Type.GetType("Message"); dObj = Activator.CreateInstance(type); BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly; MethodInfo[] finfos = type.GetMethods(flag); foreach (MethodInfo finfo in finfos) { foreach (Attribute attr in finfo.GetCustomAttributes(true)) { MsgAttribute msgA = (MsgAttribute)attr; if (msgA != null) { int name = msgA.GetMessage(); if (finfo.GetParameters().Length > 0) { //Debug.Log(name); allParameters.Add(name, finfo);//finfo.Invoke(dObj,null); allParDele.Add(name, (Action <int>)Delegate.CreateDelegate(typeof(Action <int>), msg, finfo.Name, true)); } else { //Debug.Log(name); allNoParameters.Add(name, finfo);//finfo.Invoke(dObj,null); allNoParDele.Add(name, (Action)Delegate.CreateDelegate(typeof(Action), msg, finfo.Name, true)); } } } } }
public override void SetUp() { AssignTestObject <MsgExample>(); stdMsgAttr = new MsgAttribute("Test"); }