예제 #1
0
        static void Main()
        {
            Publisher kris = new Publisher();

            new Subscriber("Kris", kris);
            new Subscriber("Vili", kris);

            kris.RaiseEvent();
        }
예제 #2
0
        public void check_evrthng()
        {
            var publisher = new Publisher();
            var subscriber1 = new Subscriber {Name = "boo1"};
            var subscriber2 = new Subscriber {Name = "boo2"};
            subscriber1.Subscribe(publisher);
            subscriber2.Subscribe(publisher);

            publisher.Send("foo");
            publisher.Send("f00000oo");
        }
예제 #3
0
        static void Main(string[] args)
        {
			Publisher p = new Publisher();
			Subscriber s = new Subscriber();

			p.SimpleEvent += s.MethodA;
			p.SimpleEvent += s.MethodB;
			p.RaiseTheEvent();

			p.SimpleEvent -= s.MethodB;
			p.RaiseTheEvent();
		}
예제 #4
0
        static void Main(string[] args)
        {
            Console.Write("Input seconds between publishing: ");
            int t = int.Parse(Console.ReadLine());
            Publisher publisher = new Publisher();
            Subscriber subscriber = new Subscriber("subscriber", publisher);

            while (true)
            {
                publisher.Greet();
                Thread.Sleep(t * 1000);
            }
        }
예제 #5
0
        public Subscriber(string name, Publisher pub)
        {
            this.Name = name;

            pub.RaiseCustomEvent += HandleCustomEvent;
        }
 public Subscriber(string ID, Publisher pub)
 {
     this.id = ID;
     pub.RaiseCustomEvent += HandleCustomEvent;
 }
예제 #7
0
        public void FactMethodName()
        {
            string raisedMessage = null;
            var publisher = new Publisher();
            publisher.MessageSent += (obj, args) => raisedMessage = args.Message;

            publisher.Send("some message");

            raisedMessage.Should().Be("some message");
        }