Example #1
0
        public static void Test()
        {
            var collection = new ConcreteAggregate<string>
              {
                "Item 0", "Item 1", "Item 2", "Item 3", "Item 4"
              };

            IEnumerator<string> enumerator = collection.GetEnumerator();
        }
        private static void ClearImplementationDemo()
        {
            var aggregate = new ConcreteAggregate();
            aggregate[0] = "Item A";
            aggregate[1] = "Item B";
            aggregate[2] = "Item C";
            aggregate[3] = "Item D";

            IIterator iterator = new ConcreteIterator(aggregate);

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

            while (!iterator.IsDone())
            {
                Console.WriteLine(iterator.CurrentItem());
                iterator.Next();
            }
        }
        /// <summary>
        /// Entry point into console application.
        /// </summary>
        static void Demo()
        {
            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();
        }
  public static void Main(string[] args)
  {   
    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);

    // Iterate over collection
    object item = i.First();

    while( item != null )
    {
      Console.WriteLine( item );
      item = i.Next();
    } 
  }
    static void Main()
    {
        ConcreteAggregate aggregate = new ConcreteAggregate();

        aggregate[0] = "Item A";
        aggregate[1] = "Item B";
        aggregate[2] = "Item C";
        aggregate[3] = "Item D";
        aggregate[4] = "Bob";

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

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

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

        // Wait for user 
        Console.ReadKey();
    }
 public ConcreteIterator(ConcreteAggregate collection)
 {
     this.Collection = collection;
     position        = 0;
 }
 public ConcreteIterator(ConcreteAggregate aggregate)
 {
     Aggregate = aggregate;
 }
 // Constructor
 public ConcreteIterator(ConcreteAggregate <T> aggregate)
 {
     this._aggregate = aggregate;
 }
 public ConcreteIteratorDesc(ConcreteAggregate aggregate)
 {
     this.aggregate = aggregate;
     this.current = aggregate.Count - 1;
 }
Example #10
0
 public ConcreteIteratorDesc(ConcreteAggregate aggregate)
 {
     _aggregate = aggregate;
     _current   = _aggregate.TotalCount - 1;
 }
Example #11
0
 /// <summary>
 /// 初始化时将具体的聚集对象传入
 /// </summary>
 /// <param name="aggregate"></param>
 public ConcreteIteratorDesc(ConcreteAggregate aggregate)
 {
     this.aggregate = aggregate;
     current        = aggregate.Count - 1;
 }
Example #12
0
        public ConcreteIterator(ConcreteAggregate agg)
        {
            _concreteAggregate = agg;

            _index = 0;
        }
Example #13
0
 private int cursor;                //定义一个游标,用于记录当前访问位置
 public ConcreteIterator(ConcreteAggregate objects)
 {
     this.objects = objects;
 }
 public ConcreteIterator(ConcreteAggregate concreteAggregate)
 {
     this._concreteAggregate = concreteAggregate;
 }
 public ConcreteIterator(ConcreteAggregate aggregate)
 {
     this.aggregate = aggregate;
 }
Example #16
0
 public CategoryIterator(ConcreteAggregate categoryAggregate)
 {
     _aggregate = categoryAggregate;
 }
Example #17
0
 public ConcreteIterator(ConcreteAggregate <T> aggregate)
 {
     _aggregate = aggregate;
     _current   = 0;
 }