예제 #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();
        }
예제 #2
0
        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();
            }
        }
예제 #3
0
        /// <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();
        }
예제 #4
0
  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();
    } 
  }
예제 #5
0
    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;
 }
예제 #7
0
 public ConcreteIterator(ConcreteAggregate aggregate)
 {
     Aggregate = aggregate;
 }
 // Constructor
 public ConcreteIterator(ConcreteAggregate <T> aggregate)
 {
     this._aggregate = aggregate;
 }
예제 #9
0
 public ConcreteIteratorDesc(ConcreteAggregate aggregate)
 {
     this.aggregate = aggregate;
     this.current = aggregate.Count - 1;
 }
예제 #10
0
 public ConcreteIteratorDesc(ConcreteAggregate aggregate)
 {
     _aggregate = aggregate;
     _current   = _aggregate.TotalCount - 1;
 }
예제 #11
0
 /// <summary>
 /// 初始化时将具体的聚集对象传入
 /// </summary>
 /// <param name="aggregate"></param>
 public ConcreteIteratorDesc(ConcreteAggregate aggregate)
 {
     this.aggregate = aggregate;
     current        = aggregate.Count - 1;
 }
예제 #12
0
        public ConcreteIterator(ConcreteAggregate agg)
        {
            _concreteAggregate = agg;

            _index = 0;
        }
예제 #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;
 }
예제 #16
0
 public CategoryIterator(ConcreteAggregate categoryAggregate)
 {
     _aggregate = categoryAggregate;
 }
예제 #17
0
 public ConcreteIterator(ConcreteAggregate <T> aggregate)
 {
     _aggregate = aggregate;
     _current   = 0;
 }