/// <summary>
        /// Entry point into console application.
        /// </summary>
        private static void Main()
        {
            ConcreteAggregate a = new ConcreteAggregate();

            a[0] = "Item A";
            a[1] = "Item B";
            a[2] = "Item C";
            a[3] = "Item D";

            // Create Iterator and provide aggregate
            ConcreteIterator i = new ConcreteIterator(a);

            Console.WriteLine("Iterating over collection:");

            object item = i.First();

            while (item != null)
            {
                Console.WriteLine(item);
                item = i.Next();
            }

            // Wait for user
            Console.ReadKey();
        }
예제 #2
0
        public void Test()
        {
            var aggregate = new ConcreteAggregate();

            aggregate[0] = "Item 1";
            aggregate[1] = "Item 2";
            aggregate[2] = "Item 3";
            var iterator = new ConcreteIterator(aggregate);

            Console.WriteLine(iterator.First());
            while (!iterator.IsDone)
            {
                Console.WriteLine(iterator.Next());
            }
            Console.WriteLine(iterator.Current);
            iterator.First();
            Console.WriteLine(iterator.Current);
        }
        /// <summary>
        /// Entry point into console application.
        /// </summary>
        private static void Main()
        {
            ConcreteAggregate a = new ConcreteAggregate();
              a[0] = "Item A";
              a[1] = "Item B";
              a[2] = "Item C";
              a[3] = "Item D";

              // Create Iterator and provide aggregate
              ConcreteIterator i = new ConcreteIterator(a);

              Console.WriteLine("Iterating over collection:");

              object item = i.First();
              while (item != null)
              {
            Console.WriteLine(item);
            item = i.Next();
              }

              // Wait for user
              Console.ReadKey();
        }