forked from WeihanLi/DesignPatterns
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAggregate.cs
More file actions
31 lines (26 loc) · 711 Bytes
/
Aggregate.cs
File metadata and controls
31 lines (26 loc) · 711 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System.Collections.Generic;
namespace IteratorPattern
{
internal abstract class Aggregate
{
/// <summary>
/// 创建迭代器
/// </summary>
/// <returns></returns>
public abstract Iterator CreateIterator();
}
internal class ConcreteAggregate : Aggregate
{
private readonly IList<object> _items = new List<object>();
public override Iterator CreateIterator()
{
return new ConcreteIterator(this);
}
public int TotalCount => _items.Count;
public object this[int index]
{
get => _items[index];
set => _items.Insert(index, value);
}
}
}