public void AddListener(object evt, EmptyCallback callback) { IBinding binding = GetBinding(evt); string mapKey = evt.ToString() + "-" + callback.Method.Name; //if (EventsDic == null) // EventsDic = Resources.Load<RV_IntDictionary>("TestData/EventsDictionary"); //else if (EventsDic.value != null) //{ // if (!EventsDic.value.ContainsKey(mapKey)) // EventsDic.value[mapKey] = 1; // else // EventsDic.value[mapKey] = EventsDic.value[mapKey] + 1; //} if (binding == null) { Bind(evt).To(callback); } else { binding.To(callback); } }
public static void AnonHandler(EmptyCallback handler) { if (handler != null) { handler(); } }
public EventCallbackType TypeForCallback(EmptyCallback callback) { if (callbackTypes.ContainsKey (callback)) { return callbackTypes [callback]; } return EventCallbackType.NOT_FOUND; }
public EventCallbackType TypeForCallback(EmptyCallback callback) { if (callbackTypes.ContainsKey(callback)) { return(callbackTypes[callback]); } return(EventCallbackType.NOT_FOUND); }
public bool HasListener(object evt, EmptyCallback callback) { IEventBinding binding = GetBinding(evt) as IEventBinding; if (binding == null) { return(false); } return(binding.TypeForCallback(callback) != EventCallbackType.NOT_FOUND); }
public static void ListenOnceForOne(this IEventDispatcher dispatcher, object returnEvent, EmptyCallback callback) { EmptyCallback intermediary = null; intermediary = () => { dispatcher.RemoveListener(returnEvent, intermediary); callback.Invoke(); }; dispatcher.AddListener(returnEvent, intermediary); }
public void UpdateListener(bool toAdd, object evt, EmptyCallback callback) { if (toAdd) { AddListener(evt, callback); } else { RemoveListener(evt, callback); } }
/// Remove a previously registered observer with exactly no arguments from this Dispatcher public static void RemoveListenerStrangeEvent(object evt, EmptyCallback callback) { if (strangeDispatcher != null) { strangeDispatcher.RemoveListener(evt, callback); } else { Debug.LogWarning("strangeDispatcher Not Ready"); } }
public void ShowForm() { if (this.InvokeRequired) { EmptyCallback d = new EmptyCallback(ShowForm); this.Invoke(d, null); } else { this.Show(); MonitorTimer.Enabled = true; } }
public void AddListener(object evt, EmptyCallback callback) { IBinding binding = GetBinding(evt); if (binding == null) { Bind(evt).To(callback); } else { binding.To(callback); } }
public void RemoveListener(object evt, EmptyCallback callback) { IBinding binding = GetBinding(evt); RemoveValue(binding, callback); string mapKey = evt.ToString() + "-" + callback.Method.Name; //if (EventsDic != null & EventsDic.value != null & EventsDic.value.ContainsKey(mapKey)) //{ // EventsDic.value[mapKey] = EventsDic.value[mapKey] - 1; // if (EventsDic.value[mapKey] <= 0) // EventsDic.value.Remove(mapKey); //} }
/// Remove a previously registered observer with exactly no arguments from this Dispatcher public static void RemoveListenerStrangeEvent(object evt, EmptyCallback callback) { if (strangeDispatcher == null && instance != null && instance.context != null) { if ((instance.context as MainContextInput).dispatcher != null) { strangeDispatcher = (instance.context as MainContextInput).dispatcher; } } if (strangeDispatcher != null) { strangeDispatcher.RemoveListener(evt, callback); } else { Debug.LogError("strangeDispatcher Not Redy"); } }
public static UniRx.IObservable <object> ToObservable(this IEventDispatcher dispatcher, object[] returns) { if (returns == null || returns.Length == 0) { throw new ArgumentNullException("returns not valid"); } Subject <object> notYetReturned = new Subject <object>(); List <object> returnsLeft = new List <object>(returns); for (int i = 0; i < returns.Length; i++) { object ret = returns[i]; EmptyCallback handler = null; handler = () => { if (!returnsLeft.Contains(ret)) { throw new Exception("Something went wrong..."); } dispatcher.RemoveListener(ret, handler); returnsLeft.Remove(ret); notYetReturned.OnNext(ret); if (returnsLeft.Count == 0) { notYetReturned.OnCompleted(); } }; dispatcher.AddListener(ret, handler); } return(notYetReturned); }
/// Remove a previously registered observer with exactly no arguments from this Dispatcher public void RemoveListener(object evt, EmptyCallback callback) { UnmapListener(evt, callback); dispatcher.RemoveListener(evt, callback); }
public IEventBinding To(EmptyCallback value) { base.To(value); storeMethodType(value as Delegate); return(this); }
public static void DispatchAndListen(this IEventDispatcher dispatcher, Action requestAction, object returnEvent, EmptyCallback callback) { dispatcher.ListenOnceForOne(returnEvent, callback); requestAction.Invoke(); }
public static void AnonHandler(EmptyCallback handler) { if(handler != null) { handler(); } }
public SL(BaseSignal listeningOn, EmptyCallback callback) : base(listeningOn) { this.callback = callback; }
public void RemoveListener(object evt, EmptyCallback callback) { IBinding binding = GetBinding(evt); RemoveValue(binding, callback); }
public void Dispatch(object eventType, object data) { //Scrub the data to make eventType and data conform if possible if (eventType == null) { throw new EventDispatcherException("Attempt to Dispatch to null.\ndata: " + data, EventDispatcherExceptionType.EVENT_KEY_NULL); } else if (eventType is IEvent) { //Client provided a full-formed event data = eventType; eventType = (data as IEvent).type; } else if (data == null) { //Client provided just an event ID. Create an event for injection data = new TmEvent(eventType, this, null); } else if (data is IEvent) { //Client provided both an evertType and a full-formed IEvent (data as IEvent).type = eventType; } else { //Client provided an eventType and some data which is not a IEvent. data = new TmEvent(eventType, this, data); } bool continueDispatch = true; if (triggerClients != null) { isTriggeringClients = true; foreach (ITriggerable trigger in triggerClients) { if (!trigger.Trigger(eventType, data)) { continueDispatch = false; } } if (triggerClientRemovals != null) { flushRemovals(); } isTriggeringClients = false; } if (!continueDispatch) { return; } IEventBinding binding = GetBinding(eventType) as IEventBinding; if (binding == null) { return; } object[] callbacks = binding.value as object[]; if (callbacks == null) { return; } int bb = callbacks.Length; for (int b = 0; b < bb; b++) { object callback = callbacks [b]; object[] parameters = null; if (callback is EventCallback) { parameters = new object[1]; parameters [0] = data; EventCallback evtCb = callback as EventCallback; try { evtCb(parameters [0] as IEvent); } catch (InvalidCastException) { object tgt = evtCb.Target; string methodName = (callback as Delegate).Method.Name; string message = "An EventCallback is attempting an illegal cast. One possible reason is not typing the payload to IEvent in your callback. Another is illegal casting of the data.\nTarget class: " + tgt + " method: " + methodName; throw new EventDispatcherException(message, EventDispatcherExceptionType.TARGET_INVOCATION); } } else if (callback is EmptyCallback) { parameters = new object[0]; EmptyCallback emptyCb = callback as EmptyCallback; emptyCb(); } } }
public abstract void SetInputCallback(EmptyCallback callback);
//SendBookingPaymentMail internal static void SendBookingPaymentMailAsync(List<BookingPayment> paymentList, EmptyCallback callback) { Guid callerKey = Guid.NewGuid(); ApartmentServiceClient proxy = GetProxy(callerKey, callback); proxy.SendBookingPaymentMailCompleted += new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(proxy_VoidMethodCompleted); proxy.SendBookingPaymentMailAsync(paymentList, callerKey); }
public EL(object returnEvent, EmptyCallback callback) : base(returnEvent) { this.callback = callback; }
internal static void SaveUserRoleAuthAsync(List<UserRoleAuth> saveList, EmptyCallback callback) { Guid callerKey = Guid.NewGuid(); ApartmentServiceClient proxy = GetProxy(callerKey, callback); proxy.SaveUserRoleAuthCompleted += new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(proxy_VoidMethodCompleted); proxy.SaveUserRoleAuthAsync(saveList, callerKey); }
//SaveBookingRoomEquipmentDetail internal static void SaveBookingRoomEquipmentDetailAsync(List<BookingRoomEquipmentDetail> saveList, EmptyCallback callback) { Guid callerKey = Guid.NewGuid(); ApartmentServiceClient proxy = GetProxy(callerKey, callback); proxy.SaveBookingRoomEquipmentDetailCompleted += new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(proxy_VoidMethodCompleted); proxy.SaveBookingRoomEquipmentDetailAsync(saveList, callerKey); }
public IEventBinding To(EmptyCallback value) { base.To (value); storeMethodType(value as Delegate); return this; }
/// Add an observer with exactly no arguments to this Dispatcher public void AddListener(object evt, EmptyCallback callback) { MapListener(evt, callback); dispatcher.AddListener(evt, callback); }
public static void DispatchAndListen(this IEventDispatcher dispatcher, object requestEvent, object returnEvent, EmptyCallback callback) { dispatcher.ListenOnceForOne(returnEvent, callback); dispatcher.Dispatch(requestEvent); }