internal void Init(IChannel channel, object message, MethodInvoke info) { mFilterIndex = -1; Channel = channel; Message = message; Filters = info.Filters; InvokeInfo = info; }
public static bool Invoke(IChannel channel, object msg) { MethodInvoke ii = GetInvokeInfo(msg.GetType()); if (ii != null) { if (ii.UseThreadPool) { System.Threading.ThreadPool.QueueUserWorkItem(OnInvoke, new object[] { channel, msg, ii }); } else { OnInvoke(new object[] { channel, msg, ii }); } return(true); } return(false); }
private static void MakeInvoke(Type type, object target, FilterAttribute[] filters) { foreach (MethodInfo method in type.GetMethods(BindingFlags.Public | BindingFlags.Instance)) { ParameterInfo[] pis = method.GetParameters(); if (pis.Length == 2 && pis[0].ParameterType == typeof(IChannel)) { List<Type> types = GetSkipFilter(method); MethodInvoke info = new MethodInvoke(); info.Handler = new MethodHandler(method); info.Target = target; info.UseThreadPool = Functions.GetMethodAttributes<UseThreadPool>(method, false).Length > 0; foreach (FilterAttribute fa in filters) { if (!types.Contains(fa.GetType())) info.Filters.Add(fa); } foreach (FilterAttribute fa in Functions.GetMethodAttributes<FilterAttribute>(method, false)) { if (!types.Contains(fa.GetType())) info.Filters.Add(fa); } mInvokeTable[pis[1].ParameterType] = info; } } }