Skip to content

Commit 6ce26ee

Browse files
committed
Pass a strategy with the explicit interface to a context
1 parent 792ca54 commit 6ce26ee

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/BehavioralPatterns/Strategy/StrategyLibrary/ShippingExample/ShippingExecutor.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using BuildingBlocks;
33
using StrategyLibrary.ShippingExample.ShippingProviders;
4+
using StrategyLibrary.ShippingExample.ShippingProviders.Common;
45

56
namespace StrategyLibrary.ShippingExample
67
{
@@ -39,7 +40,7 @@ public static void Execute()
3940
Description = "Xiaomi Mi 10T Pro",
4041
};
4142

42-
var fedEx = new FedEx();
43+
IShippingProvider fedEx = new FedEx();
4344
var shippingCostCalculationService = new ShippingCostCalculationService(fedEx);
4445

4546
var price = shippingCostCalculationService.Calculate(order);

src/BehavioralPatterns/Strategy/StrategyLibrary/SortingExample/SortingExecutor.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using BuildingBlocks;
33
using StrategyLibrary.SortingExample.Strategies;
4+
using StrategyLibrary.SortingExample.Strategies.Common;
45

56
namespace StrategyLibrary.SortingExample
67
{
@@ -10,7 +11,7 @@ public static void Execute()
1011
{
1112
ConsoleExtension.WriteSeparator("Sorting example");
1213

13-
var sortStrategy = new SortByFirstName();
14+
ISortStrategy sortStrategy = new SortByFirstName();
1415
var sortablePersons = new SortablePersons(sortStrategy);
1516

1617
sortablePersons.Add(new Person("Dennis", "Ritchie", 1941));

0 commit comments

Comments
 (0)