static void Main(string[] args)
        {
            ConcreteAggregate aggregate = new ConcreteAggregate();

            aggregate.Add(new Category()
            {
                Name = "Csharp"
            });
            aggregate.Add(new Category()
            {
                Name = "Asp.Net"
            });
            aggregate.Add(new Category()
            {
                Name = "EntityFramework"
            });
            aggregate.Add(new Category()
            {
                Name = ".NET CORE"
            });

            IIterator iterator = aggregate.CreateIterator();

            Console.WriteLine($"İlk eleman : {((Category)iterator.First()).Name}");
            Console.WriteLine($"Son eleman : {((Category)iterator.Last()).Name}");

            while (iterator.MoveNext())
            {
                Console.WriteLine(((Category)iterator.Current()).Name);
            }

            Console.ReadLine();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            var collection = new ConcreteAggregate();

            for (int i = 0; i < 10; i++)
            {
                collection.Add($" 1 + {i} = {i + 1}");
            }

            var iterator = new ConcreteIterator(collection);

            while (!iterator.IsDone())
            {
                Console.WriteLine(iterator.Next());
            }

            Console.WriteLine($"\n Valor da primeira posição: {iterator.First()} \n");
            Console.WriteLine($" Valor da ultima posição: {iterator.CurrentPosition()}");
            Console.ReadKey();
        }