public void OnEmploiChanged(int id_en, string notification) { if (EmploiChanged != null) { EmploiChangedEvent notifDelegate = null; Delegate[] invocationList_ = null; try { invocationList_ = EmploiChanged.GetInvocationList(); } catch (MemberAccessException ex) { throw ex; } if (invocationList_ != null) { lock (this) { foreach (Delegate del in invocationList_) { notifDelegate = (EmploiChangedEvent)del; WrapperDelegate wrDel = new WrapperDelegate(BeginSend); AsyncCallback callback = new AsyncCallback(EndSend); wrDel.BeginInvoke(id_en, notification, notifDelegate, callback, wrDel); } } } } }
/// <summary> /// Broadcast message to all clients /// </summary> /// <param name="message">message string</param> public void Send(string message) { if (MessageReceived != null) { MessageHandler messageDelegate = null; Delegate[] invocationList_ = null; try { invocationList_ = MessageReceived.GetInvocationList(); } catch (MemberAccessException ex) { throw ex; } if (invocationList_ != null) { lock (this) { foreach (Delegate del in invocationList_) { messageDelegate = (MessageHandler)del; WrapperDelegate wrDel = new WrapperDelegate(BeginSend); AsyncCallback callback = new AsyncCallback(EndSend); wrDel.BeginInvoke(message, messageDelegate, callback, wrDel); } } } } }
private MethodProxy(Context context, bool raw, object hardTarget, MethodBase method, ParameterInfo[] Parameters, WrapperDelegate fastWrapper, bool forceInstance) : base(context) { _raw = raw; _hardTarget = hardTarget; _method = method; _parameters = Parameters; _fastWrapper = fastWrapper; _forceInstance = forceInstance; RequireNewKeywordLevel = RequireNewKeywordLevel.WithoutNewOnly; }
private void EndSend(IAsyncResult result) { WrapperDelegate wrDel = (WrapperDelegate)result.AsyncState; wrDel.EndInvoke(result); }
public BasicWrapper(WrapperDelegate wrapper, string name, params object[] wrapperParams) { Name = name; this.wrapper = wrapper; this.Params = string.Join(", ", wrapperParams); }
public BasicWrapper(WrapperDelegate wrapper, string name, string wrapperParams) { Name = name; Params = wrapperParams; this.wrapper = wrapper; }
public MethodProxy(Context context, MethodBase methodBase, object hardTarget) : base(context) { _method = methodBase; _hardTarget = hardTarget; _parameters = methodBase.GetParameters(); _strictConversion = methodBase.IsDefined(typeof(StrictConversionAttribute), true); _name = methodBase.Name; if (methodBase.IsDefined(typeof(JavaScriptNameAttribute), false)) { _name = (methodBase.GetCustomAttributes(typeof(JavaScriptNameAttribute), false).First() as JavaScriptNameAttribute).Name; if (_name.StartsWith("@@")) { _name = _name.Substring(2); } } if (_length == null) { _length = new Number(0) { _attributes = JSValueAttributesInternal.ReadOnly | JSValueAttributesInternal.DoNotDelete | JSValueAttributesInternal.DoNotEnumerate | JSValueAttributesInternal.SystemObject } } ; if (methodBase.IsDefined(typeof(ArgumentsCountAttribute), false)) { var argsCountAttribute = methodBase.GetCustomAttributes(typeof(ArgumentsCountAttribute), false).First() as ArgumentsCountAttribute; _length._iValue = argsCountAttribute.Count; } else { _length._iValue = _parameters.Length; } for (int i = 0; i < _parameters.Length; i++) { if (_parameters[i].IsDefined(typeof(ConvertValueAttribute), false)) { var t = _parameters[i].GetCustomAttributes(typeof(ConvertValueAttribute), false).First(); if (_paramsConverters == null) { _paramsConverters = new ConvertValueAttribute[_parameters.Length]; } _paramsConverters[i] = t as ConvertValueAttribute; } } var methodInfo = methodBase as MethodInfo; if (methodInfo != null) { _returnConverter = methodInfo.ReturnParameter.GetCustomAttribute(typeof(ConvertValueAttribute), false) as ConvertValueAttribute; _forceInstance = methodBase.IsDefined(typeof(InstanceMemberAttribute), false); if (_forceInstance) { if (!methodInfo.IsStatic || (_parameters.Length == 0) || (_parameters.Length > 2) || (_parameters[0].ParameterType != typeof(JSValue)) || (_parameters.Length > 1 && _parameters[1].ParameterType != typeof(Arguments))) { throw new ArgumentException("Force-instance method \"" + methodBase + "\" has invalid signature"); } _raw = true; } if (!WrapperCache.TryGetValue(methodBase, out _fastWrapper)) { WrapperCache[methodBase] = _fastWrapper = makeFastWrapper(methodInfo); } _raw |= _parameters.Length == 0 || (_parameters.Length == 1 && _parameters[0].ParameterType == typeof(Arguments)); RequireNewKeywordLevel = RequireNewKeywordLevel.WithoutNewOnly; } else if (methodBase is ConstructorInfo) { if (!WrapperCache.TryGetValue(methodBase, out _fastWrapper)) { WrapperCache[methodBase] = _fastWrapper = makeFastWrapper(methodBase as ConstructorInfo); } _raw |= _parameters.Length == 0 || (_parameters.Length == 1 && _parameters[0].ParameterType == typeof(Arguments)); } else { throw new NotImplementedException(); } }
public static void RunTask <TParam>(WrapperDelegate <TParam> task, TParam parameters) { task.Invoke(parameters); }
public static void RunTask <TParam>(WrapperDelegate <TParam> task) { RunTask(task, default(TParam)); }