public void Resolve_many_should_return_matching_contvariant_generic_service() { var eventHandler = new EvntHandler(); var eventInfo = new FiredEventInfo(); var eventProvider = new DryIocEventProvider(); eventProvider.AddHandler(eventHandler); eventProvider.FireEvent <IHandledEventInfo>(eventInfo); Assert.AreEqual(1, eventHandler.HandledCount); eventProvider.FireEvent(eventInfo); Assert.AreEqual(2, eventHandler.HandledCount); }
private void AttachHandle(string nameEvent, object keyObj, EvntHandler handler) { DictEventHands[nameEvent] += handler; if (keyObj != null) DictLists.Add(keyObj, new KeyValuePair<string, EvntHandler>(nameEvent, handler)); }
private void RegisterEventAndAttach(string nameEvent, object keyObj, EvntHandler handler) { if (!DictEventHands.ContainsKey(nameEvent)) DictEventHands.Add(nameEvent, null); AttachHandle(nameEvent, keyObj, handler); }
/// <summary> /// Отказ от прослушивания события /// </summary> /// <param name="nameEvent">Идентификатор события</param> /// <param name="handler">Ссылка на метод обработчик</param> public void UnlistenEvent(object keyObj, EvntHandler handler, params string[] nameEvents) { EvntHandler hnd; if (nameEvents != null) foreach (var item in nameEvents) if (DictEventHands.TryGetValue(item, out hnd)) { DictEventHands[item] = (EvntHandler)Delegate.Remove(hnd, handler); if (DictLists.Contains(keyObj)) DictLists[keyObj].Remove(new KeyValuePair<string, EvntHandler>(item, handler)); } }
/// <summary> /// Установка прослушивания события /// </summary> /// <param name="evidence">Мандат (разрешение) на прослушивание</param> /// <param name="nameEvent">Идентификатор события</param> /// <param name="handler">Ссылка на метод обработчик</param> public void ListenEvent(object keyObj, EvntHandler handler, params string[] nameEvents) { if (nameEvents != null) foreach (var item in nameEvents) if (DictEventHands.ContainsKey(item)) AttachHandle(item, keyObj, handler); }
public void UnlistenEvent(object keyObj, EvntHandler handler, params string[] nameEvents) { }
public void ListenEvent(object keyObj, EvntHandler handler, params string[] nameEvents) { evntMan.ListenEvent(keyObj, handler, nameEvents); }