コード例 #1
0
        private static void CompositeDesignPattern()
        {
            var items             = new ProductCatalog("Ürünler");
            var phones            = new ProductCatalog("Telefonlar");
            var iphone            = new ProductCatalog("İphone Telefon");
            var samsung           = new ProductCatalog("Samsung Telefon");
            var iphone5Item       = new DesignPattern.Structural.Composite.Product("Iphone 5");
            var samsungGalaxyItem = new DesignPattern.Structural.Composite.Product("Samsung Galaxy");

            //En Üst hiyararşiye Telefonlar eklendi
            items.Add(phones);
            //Telefonlar hiyararşisine iphone ve samsung ekledik
            phones.Add(iphone);
            phones.Add(samsung);

            //Iphone ve samsung hiyerarşisine Iphone5 ve samsung galaxy ekledik
            iphone.Add(iphone5Item);
            samsung.Add(samsungGalaxyItem);
            //hiyerarşiyi ekrana yazdık
            items.Hierarchy();
        }