// Creating a chain of behaviors var chain = new BehaviorChain(); chain.AddBehavior(new MultiplyByTwoBehavior()); chain.AddBehavior(new AddFiveBehavior()); // Executing the chain int input = 10; int result = chain.Execute(input); // Output: (10 * 2) + 5 = 25 Console.WriteLine(result);
// Creating a chain of behaviors var chain = new BehaviorChainIn this example, we create a chain of behaviors that formats the input string to uppercase and then logs it. The input is "example", so the output will be "Formatted string: EXAMPLE, Logging: EXAMPLE". The package library for BehaviorChain is "BehaviorChain.Core".(); chain.AddBehavior(new FormatStringBehavior()); chain.AddBehavior(new LogBehavior()); // Executing the chain string input = "example"; string result = chain.Execute(input); // Output: Formatted string: EXAMPLE, Logging: EXAMPLE Console.WriteLine(result);