-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBridgeAbstractionsImpl.cs
More file actions
48 lines (39 loc) · 1.47 KB
/
Copy pathBridgeAbstractionsImpl.cs
File metadata and controls
48 lines (39 loc) · 1.47 KB
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
42
43
44
45
46
47
48
using GofPatterns.Core.Extensions;
namespace GofPatterns.Structural.BridgePattern.Implementations;
/// <summary>
/// Bridge abstraction interface with multiple implementations.
/// </summary>
/// <typeparam name="TImplementation"></typeparam>
public class BridgeAbstractionsImpl<TImplementation> : IBridgeAbstractionsImpl<TImplementation>
where TImplementation : IBridgeImplementationImpl
{
private readonly List<TImplementation> impls = new();
public void Add(TImplementation implementation, params TImplementation[] implementations)
{
impls.Build(implementation, implementations);
}
public void Execute()
{
impls.ForEach(impl => impl.Execute());
}
public int ImplementationCount => impls.Count;
}
/// <summary>
/// Bridge abstraction interface with multiple implementations and input.
/// </summary>
/// <typeparam name="TImplementation"></typeparam>
/// <typeparam name="TInput"></typeparam>
public class BridgeAbstractionsImpl<TImplementation, TInput> : IBridgeAbstractionsImpl<TImplementation, TInput>
where TImplementation : IBridgeImplementationImpl<TInput>
{
private readonly List<TImplementation> impls = new();
public void Add(TImplementation implementation, params TImplementation[] implementations)
{
impls.Build(implementation, implementations);
}
public void Execute(TInput input)
{
impls.ForEach(impl => impl.Execute(input));
}
public int ImplementationCount => impls.Count;
}