public void TestAddAll()
        {
            IMultiMap <int, int> map = HashMultiMap <int, int> .Create();

            map.Add(2, 5);
            map.Add(2, 4);
            map.Add(2, 3);
            map.Add(1, 5);
            map.Add(1, 6);
            IMultiMap <int, int> map2 = HashMultiMap <int, int> .Create();

            map.Add(7, 5);
            map.Add(7, 4);
            map.Add(7, 3);
            map.Add(8, 5);
            map.Add(8, 6);
            map.AddAll(map2);
            foreach (int key in map2.Keys)
            {
                Assert.IsTrue(map.ContainsKey(key));
                foreach (int value in map2.Get(key))
                {
                    Assert.IsTrue(map.ContainsValue(value));
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Register the instance as subscriber through atrribute subscribe.
        /// </summary>
        /// <param name="object">Instance to registred as subscriber to events.</param>
        public void Register(Object @object)
        {
            IMultiMap <Type, EventHandler> methodsInSubscriber = finder.FindAllHandlers(@object);

            handlersByTypeLock.EnterWriteLock();
            try
            {
                handlersByType.AddAll(methodsInSubscriber);
            }
            catch (Exception e)
            {
                //add  logger message.
            }
            finally
            {
                handlersByTypeLock.ExitWriteLock();
            }
        }