public void HandleEvent() { var publisher = new Publisher( assembly: Assembly.GetExecutingAssembly(), ns: typeof(PublisherTest.Person).Namespace); var aunt1 = new Aunt(); var aunt2 = new Aunt(); var uncle = new Uncle(); publisher.Subscribe(aunt1); publisher.Subscribe(aunt2); publisher.Subscribe(uncle); publisher.Publish(new Newspaper()); publisher.Publish(new Newspaper()); publisher.Publish(new Ticket()); Assert.Equal(2, aunt1.NewspaperCount); Assert.Equal(1, aunt1.TicketCount); Assert.Equal(2, aunt2.NewspaperCount); Assert.Equal(1, aunt2.TicketCount); Assert.Equal(0, uncle.TicketCount); Assert.Equal(2, uncle.NewspaperCount); }
public UncleBlockSerializer(Uncle uncle) : base(new BaseSerializer[] { new HeaderSerializer(uncle.Header), new FixVecSerializer <byte[], ProposalShortIdSerializer>(uncle.Proposals.Select(p => HexStringToBytes(p)).ToArray()), }) { }
static void Inheritence() { GrandFather surya = new GrandFather("Surya"); Father Chandra = new Father("Chandra", "Jung"); Uncle Hari = new Uncle("Hari"); Me Shyam = new Me("Shyam"); //Console.WriteLine("Gran Father Details :"); //Console.WriteLine(surya.FirstName); //Console.WriteLine(surya.LastName); //Console.WriteLine("Father's Detail :"); //Console.WriteLine(Chandra.FirstName + " " + Chandra.MiddleName + " " + Chandra.LastName); //Console.WriteLine("Uncle's Detail :"); //Console.WriteLine(Hari.FirstName + " " + Hari.LastName); //Console.WriteLine("My Details : "); //Console.WriteLine(Shyam.FirstName + " " + Shyam.MiddleName + " " + Shyam.LastName); Console.WriteLine(surya.ToString()); Console.WriteLine(Chandra.ToString()); }
static void Main(string[] args) { #region Soda var colas = new Cola(210); colas.Flavours.Add(new VanillaCola(215)); colas.Flavours.Add(new CherryCola(210)); var lemonLime = new LemonLime(185); var rootBeers = new RootBeer(195); rootBeers.Flavours.Add(new VanillaRootBeer(200)); rootBeers.Flavours.Add(new StrawberryRootBeer(200)); SodaWater sodaWater = new SodaWater(180); sodaWater.Flavours.Add(colas); sodaWater.Flavours.Add(lemonLime); sodaWater.Flavours.Add(rootBeers); sodaWater.DisplayCalories(0); #endregion #region Family // Parent 1 Person john = new Person("John"); // Parent 2 Person jane = new Person("Jane"); // Child 1 Person alice = new Person("Alice"); // Child 2 Person billy = new Person("Billy"); // Child 3 Person christine = new Person("Christine"); // John and Jane are both parents of Alice john.AddChild(alice); jane.AddChild(alice); // John is also Billy's parent john.AddChild(billy); // Jane is also Christine's parent jane.AddChild(christine); // Since David is John's brother he is also an uncle. Uncle david = new Uncle("David"); // David and John are both the children of their father Edward. Person edward = new Person("Edward"); edward.AddChild(john); // Even though 'david' is class of Uncle it can still be added // as a child. edward.AddChild(david); #endregion Console.ReadKey(); }