/// <summary> /// 注册方法 /// </summary> /// <param name="functionKey">方法标识</param> /// <param name="serviceKey">服务标识</param> /// <param name="serviceName">名称</param> /// <param name="description">描述信息</param> /// <param name="offline">离线标志</param> /// <param name="methodInfo">方法信息对象</param> /// <param name="dataUpdateEvent">数据更新事件签名</param> private void RegisterFunction(string functionKey, string serviceKey, string serviceName, string description, bool offline, MethodInfo methodInfo, string dataUpdateEvent) { if (!subsystems.ContainsKey(serviceKey)) { throw new ArgumentException("在注册[" + serviceName + "]服务时发现SystemManager并不已经存在Key为[" + serviceKey + "]的子系统信息", "subsystemKey"); } ServiceInfo subsystem = subsystems[serviceKey]; subsystem.AddService(new RemoteMethodInfo(functionKey, serviceKey, serviceName, description, offline, methodInfo, dataUpdateEvent)); invokers.Add(methodInfo, DynamicInvoker.GetMethodInvoker(methodInfo)); }
/// <summary> /// 获取方法的动态调用器 /// </summary> /// <param name="method">The method.</param> /// <returns></returns> public DynamicInvokerHandler GetDynamicInvoker(MethodInfo method) { if (invokers.ContainsKey(method)) { return(invokers[method]); } else { try { logger.Debug(String.Format("生成方法 \"{0}\" 的调用器", method)); //if (method.IsGenericMethod) // method = method.GetGenericMethodDefinition(); DynamicInvokerHandler invoker = DynamicInvoker.GetMethodInvoker(method); invokers[method] = invoker; return(invoker); } catch (Exception ex) { throw ex; } } }
private void InvokeMehtod(object target, MethodInfo method, EventArgs e) { DynamicInvokerHandler invoker = DynamicInvoker.GetMethodInvoker(method); invoker(target, new object[] { null, e }); }