-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComposite.cs
More file actions
41 lines (37 loc) · 916 Bytes
/
Copy pathComposite.cs
File metadata and controls
41 lines (37 loc) · 916 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
32
33
34
35
36
37
38
39
40
41
using System;
using System.Collections.Generic;
namespace CompositePattern
{
public class Composite : Component
{
public override void Operation()
{
foreach (Component c in components)
{
c.Operation();
}
//Some ational stuff can be added.
}
private List<Component> components;
protected Composite(string name)
: base(name)
{
components = new List<Component>();
}
public override void Add(Component component)
{
components.Add(component);
}
public override void Remove(Component component)
{
components.Remove(component);
}
public override IEnumerable<Component> CreateIterator
{
get
{
return components;
}
}
}
}