-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCorPatternExampleWithOutput.cs
More file actions
40 lines (31 loc) · 1.39 KB
/
CorPatternExampleWithOutput.cs
File metadata and controls
40 lines (31 loc) · 1.39 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
using GofConsoleApp.Examples.Behavioral.CorPattern.InputWithOutputComponents;
using GofPatterns.Behavioral.ChainOfResponsibilityPattern.Orchestrators;
using GofPatterns.Behavioral.ChainOfResponsibilityPattern.Orchestrators.Simple;
namespace GofConsoleApp.Examples.Behavioral.CorPattern;
internal class CorPatternExampleWithOutput : BaseExample
{
protected override bool Execute()
{
var orchestrator = new ResponsibilityChainOrchestrator<string, string>();
orchestrator.Append(new ResponsibilityFoo(), "FooChain");
orchestrator.Append(new ResponsibilityBar(), "BarChain");
orchestrator.Append(new ResponsibilityFooBar(), "FooBarChain");
Logger.Log("------------- START Orchestrator 1 -------------");
// Start with >>> Foo
// IsNotResponsible >> Foo (Not Executes)
// Invokes >>> Bar
// IsResponsible >>>>> Bar (Executes)
var outputBar = orchestrator.Execute("Bar");
Logger.Log(outputBar);
Logger.Log("------------- START Orchestrator 2 -------------");
// Start with >>> Foo
// IsNotResponsible >> Foo (Not Executes)
// Invokes >> Bar
// IsNotResponsible >> Bar (Not Executes)
// Invokes >> FooBar
// IsResponsible >>>>> FooBar (Executes)
var outputFooBar = orchestrator.Execute("FooBar");
Logger.Log(outputFooBar);
return true;
}
}