forked from WestDiscGolf/StrategyPatternExample
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
22 lines (17 loc) · 646 Bytes
/
Copy pathProgram.cs
File metadata and controls
22 lines (17 loc) · 646 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using StrategyPatternExample.Operators;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddScoped<IMathStrategy, MathStrategy>();
builder.Services.AddScoped<IMathOperator, AddOperator>();
builder.Services.AddScoped<IMathOperator, SubtractOperator>();
builder.Services.AddScoped<IMathOperator, MultipleOperator>();
builder.Services.AddScoped<IMathOperator, DivideOperator>();
var app = builder.Build();
app.UseHttpsRedirection();
app.MapGet("/", (IMathStrategy strategy) =>
{
int a = 10;
int b = 5;
int result = strategy.Calculate(a, b, Operator.Add);
return Results.Ok(result.ToString());
});
app.Run();