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);
        }
Пример #2
0
 private void AttachHandle(string nameEvent, object keyObj, EvntHandler handler)
 {
     DictEventHands[nameEvent] += handler;
     if (keyObj != null)
         DictLists.Add(keyObj, new KeyValuePair<string, EvntHandler>(nameEvent, handler));
 }
Пример #3
0
 private void RegisterEventAndAttach(string nameEvent, object keyObj, EvntHandler handler)
 {
     if (!DictEventHands.ContainsKey(nameEvent))
         DictEventHands.Add(nameEvent, null);
     AttachHandle(nameEvent, keyObj, handler);
 }
Пример #4
0
 /// <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));
             }
 }
Пример #5
0
 /// <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);
 }
Пример #6
0
 public void UnlistenEvent(object keyObj, EvntHandler handler, params string[] nameEvents)
 {
 }
Пример #7
0
 public void ListenEvent(object keyObj, EvntHandler handler, params string[] nameEvents)
 {
     evntMan.ListenEvent(keyObj, handler, nameEvents);
 }