-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStrategy.cs
41 lines (34 loc) · 913 Bytes
/
Strategy.cs
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
namespace DIContainers
{
public interface IStrategy
{
public string Name { get; }
public void Run();
}
public class StrategyA : IStrategy
{
public string Name { get; } = "StrategyA";
public StrategyA()
{
Console.WriteLine("The strategy A has been constructed.");
}
public void Run()
{
Console.WriteLine($"{Name} is running.");
}
}
public class StrategyB : IStrategy
{
public string Name { get; } = "StrategyB";
public StrategyB()
{
Console.WriteLine("The strategy B is infrequently used and expensive to construct");
Thread.Sleep(2000);
Console.WriteLine("The strategy B has been constructed.");
}
public void Run()
{
Console.WriteLine($"{Name} is running.");
}
}
}