static void Main() { Publisher kris = new Publisher(); new Subscriber("Kris", kris); new Subscriber("Vili", kris); kris.RaiseEvent(); }
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"); }
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(); }
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); } }
public Subscriber(string name, Publisher pub) { this.Name = name; pub.RaiseCustomEvent += HandleCustomEvent; }
public Subscriber(string ID, Publisher pub) { this.id = ID; pub.RaiseCustomEvent += HandleCustomEvent; }
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"); }