Пример #1
0
        public static void EventSamplerMain(string[] args)
        {
            // Create StorePublisher instance
            StorePublisher <string> s = new StorePublisher <string>();

            // Add first subscriber
            new StoreSubscriber <string>("Subscriber A").SubscribeToStore(s);

            // Generates events for initial clear and the add
            s.Add(MYID, "Store Ham");

            // Generates an add event
            s.Add(MYID, "Store Eggs");

            // Add second subscriber
            new StoreSubscriber <string>("Subscriber B").SubscribeToStore(s);

            // Both subscribers are notified of add
            s.Add(MYID, "Store Milk");

            // Both subscribers are notified of clear
            s.Clear(MYID);
        }
Пример #2
0
 /// <summary>
 /// We subscribe to both StorePublisher events.
 /// </summary>
 /// <param name='store'>
 /// Store.
 /// </param>
 public void SubscribeToStore(StorePublisher <T> store)
 {
     store.RaiseClearedEvent += new EventHandler <ClearEventArgs>(OnClearEvent);
     store.RaiseStoredEvent  += new EventHandler <StoreEventArgs <T> >(OnStoreEvent);
 }