private void PublishEvents()
 {
     FaultHandledOperations.ExecuteFaultHandledOperation(() =>
     {
         _Proxy = DiscoveryPublishService <IMyEvents> .CreateChannel();
         _Proxy.OnEvent1();
         _Proxy.OnEvent2(1);
         _Proxy.OnEvent3(2, "Hello");
         //(_Proxy as ICommunicationObject).Close();
     });
 }
Ejemplo n.º 2
0
        void OnPublish(object sender, EventArgs e)
        {
            MyPublisher publisher  = new MyPublisher();
            IMyEvents   subscriber = (IMyEvents) new MySubscriber();

            publisher.Subscribe(subscriber, EventType.OnEvent1 | EventType.OnEvent2);
            publisher.SomeMethod(1);
            publisher.Unsubscribe(subscriber, EventType.OnEvent1);
            publisher.SomeMethod(2);
            publisher.Unsubscribe(subscriber, EventType.OnEvent2);
            publisher.SomeMethod(3);
            publisher.Subscribe(subscriber, EventType.OnAllEvents);
            publisher.SomeMethod(4);
            publisher.Unsubscribe(subscriber, EventType.OnAllEvents);
        }
Ejemplo n.º 3
0
 public void Unsubscribe(IMyEvents subscriber, EventType eventType)
 {
     Debug.Assert(subscriber != null);
     if ((eventType & EventType.OnEvent1) == EventType.OnEvent1)
     {
         m_Event1 -= subscriber.OnEvent1;
     }
     if ((eventType & EventType.OnEvent2) == EventType.OnEvent2)
     {
         m_Event2 -= subscriber.OnEvent2;
     }
     if ((eventType & EventType.OnEvent3) == EventType.OnEvent3)
     {
         m_Event3 -= subscriber.OnEvent3;
     }
 }