Skip to content

Commit 0d0df57

Browse files
committed
feat!: Rename DecoratorCommandStrategy to DelegatingCommandStrategy.
1 parent 716e992 commit 0d0df57

18 files changed

+47
-43
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1111
* Support for Android 11 (March, 2021)
1212

1313
### Changed
14+
* Replaced `DecoratorCommandStrategy` with `DelegatingCommandStrategy`.
1415
* Replaced `IViewModelView` with `IDispatcher`.
1516
* Replaced `IViewModel.View` with `IViewModel.Dispatcher`
1617
* Update UWP target to 19041 and net framework to 4.7.2
@@ -20,6 +21,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2021
* [#39] Change target Uno.UI version to 4.0.7.
2122

2223
### Deprecated
24+
* `DecoratorCommandStrategy` not longer exists. Use `DelegatingCommandStrategy` instead.
2325
* `IViewModelView` not longer exists. Use `IDispatcher` instead.
2426
### Removed
2527
* Support for Android 10 (March, 2022)

build/gitversion.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
assembly-versioning-scheme: MajorMinorPatch
22
mode: ContinuousDeployment
3-
next-version: 0.10.0
3+
next-version: 0.11.0
44
continuous-delivery-fallback-tag: ""
55
increment: none # Disabled as it is not used. Saves time on the GitVersion step
66
branches:

src/DynamicMvvm.Abstractions/Command/DecoratorCommandStrategy.cs

+6-4
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@
77
namespace Chinook.DynamicMvvm
88
{
99
/// <summary>
10-
/// This is a base implementation for <see cref="IDynamicCommandStrategy"/> decorators.
10+
/// This delegates the functionalities of <see cref="IDynamicCommandStrategy"/> to an inner strategy.
11+
/// You may override any member add customization.
12+
/// This class is an homologue to <see cref="System.Net.Http.DelegatingHandler"/>.
1113
/// </summary>
12-
public abstract class DecoratorCommandStrategy : IDynamicCommandStrategy
14+
public abstract class DelegatingCommandStrategy : IDynamicCommandStrategy
1315
{
1416
/// <summary>
15-
/// Initializes a new instance of the <see cref="DecoratorCommandStrategy"/> class.
17+
/// Initializes a new instance of the <see cref="DelegatingCommandStrategy"/> class.
1618
/// </summary>
17-
public DecoratorCommandStrategy()
19+
public DelegatingCommandStrategy()
1820
{
1921
}
2022

src/DynamicMvvm.Abstractions/Command/IDynamicCommand.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ var myCommand = new DynamicCommand("MyCommandFromTaskWithParameter", myCommandSt
8989
Task ExecuteCommand(CancellationToken ct, int parameter) => Task.CompletedTask;
9090
```
9191

92-
### Strategy Decorators
92+
### Delegating Strategies
9393

9494
`IDynamicCommandStrategy` can be decorated in order to add new logic to it.
9595

96-
Here is a list of some decorators provided.
96+
Here is a list of some delegating strategies provided.
9797

9898
- [BackgroundCommandStrategy](Implementations/Strategies/BackgroundCommandStrategy.cs) : Executes the command on a background thread.
9999
- [CanExecuteCommandStrategy](Implementations/Strategies/CanExecuteCommandStrategy.cs) : Attaches the `CanExecute` to the value of a `IDynamicProperty`.
@@ -116,35 +116,35 @@ var myCommand = new DynamicCommand("MyCommand", myStrategyWithLogs);
116116
void ExecuteCommand() { }
117117
```
118118

119-
You can create your own decorators by inheriting from `DecoratorCommandStrategy`.
119+
You can create your own strategies by inheriting from `DelegatingCommandStrategy`.
120120

121121
```csharp
122-
public class MyCustomCommandDecorator : DecoratorCommandStrategy
122+
public class MyCustomCommandStrategy : DelegatingCommandStrategy
123123
{
124-
public MyCustomCommandDecorator(IDynamicCommandStrategy innerStrategy) : base(innerStrategy)
124+
public MyCustomCommandStrategy(IDynamicCommandStrategy innerStrategy) : base(innerStrategy)
125125
{ }
126126

127127
public override bool CanExecute(object parameter, IDynamicCommand command)
128128
{
129-
// Implement your custom decorator logic here.
129+
// Implement your custom logic here.
130130
return base.CanExecute(parameter, command);
131131
}
132132

133133
public override async Task Execute(CancellationToken ct, object parameter, IDynamicCommand command)
134134
{
135-
// Implement your custom decorator logic here.
135+
// Implement your custom logic here.
136136
base.Execute(ct, parameter, command);
137137
}
138138
}
139139

140-
public static class MyCustomCommandDecoratorExtensions
140+
public static class MyCustomCommandStrategyExtensions
141141
{
142-
public static IDynamicCommandStrategy WithMyCustomDecorator(this IDynamicCommandStrategy strategy)
143-
=> new MyCustomCommandDecorator(strategy);
142+
public static IDynamicCommandStrategy WithMyCustomStrategy(this IDynamicCommandStrategy strategy)
143+
=> new MyCustomCommandStrategy(strategy);
144144
}
145145

146-
// This will decorate the strategy with your custom decorator
147-
var myCommandWithMyCustomDecorator = myCommandStrategy.WithMyCustomDecorator();
146+
// This will decorate the strategy with your custom one.
147+
var myCommandWithMyCustomStrategy = myCommandStrategy.WithMyCustomStrategy();
148148
```
149149

150150
### Command builder and factory

src/DynamicMvvm.Abstractions/Command/IDynamicCommandBuilder.Extensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public static class DynamicCommandBuilderExtensions
1717
/// <param name="strategy">The strategy to add.</param>
1818
/// <param name="wrapExisting">When true, the <paramref name="strategy"/> is added at the start of the list, so that it wraps all existing strategies already present in the list.</param>
1919
/// <returns><see cref="IDynamicCommandBuilder"/></returns>
20-
public static IDynamicCommandBuilder WithStrategy(this IDynamicCommandBuilder builder, DecoratorCommandStrategy strategy, bool wrapExisting = false)
20+
public static IDynamicCommandBuilder WithStrategy(this IDynamicCommandBuilder builder, DelegatingCommandStrategy strategy, bool wrapExisting = false)
2121
{
2222
if (wrapExisting)
2323
{

src/DynamicMvvm.Abstractions/Command/IDynamicCommandBuilder.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public interface IDynamicCommandBuilder
3333
/// The list of strategies that will decorate the <see cref="BaseStrategy"/>.
3434
/// The order is important: the first strategy wraps the second, which wraps the third and so on.
3535
/// </summary>
36-
IList<DecoratorCommandStrategy> Strategies { get; set; }
36+
IList<DelegatingCommandStrategy> Strategies { get; set; }
3737

3838
/// <summary>
3939
/// Creates a new instance of <see cref="IDynamicCommand"/>

src/DynamicMvvm.Abstractions/ViewModel/IViewModel.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public class MyViewModel : ViewModelBase
167167

168168
You can decorate a `IDynamicCommand` from its definition.
169169

170-
[Refer to this documention for more information on IDynamicCommand decorators](../Command/IDynamicCommand.md#decorators).
170+
[Refer to this documention for more information on IDynamicCommand strategies](../Command/IDynamicCommand.md#Delegating-Strategies).
171171

172172
```csharp
173173
public class MyViewModel : ViewModelBase

src/DynamicMvvm.Tests/Command/DynamicCommandBuilderFactoryTests.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,19 @@ public async Task It_Creates_From_Task_T()
7171
[Fact]
7272
public async Task It_Decorates_Using_Global()
7373
{
74-
var decoratorCalled = false;
74+
var configurationCalled = false;
7575

7676
var factory = new DynamicCommandBuilderFactory(Configure);
7777

7878
var command = factory.CreateFromAction(DefaultCommandName, () => { }).Build();
7979

8080
await command.Execute();
8181

82-
decoratorCalled.Should().BeTrue();
82+
configurationCalled.Should().BeTrue();
8383

8484
IDynamicCommandBuilder Configure(IDynamicCommandBuilder builder)
8585
{
86-
decoratorCalled = true;
86+
configurationCalled = true;
8787
return builder;
8888
}
8989
}
@@ -178,7 +178,7 @@ public void It_passes_ViewModel_owner_correctly_when_null()
178178

179179
private class TestParameter { }
180180

181-
private class TestStrategy : DecoratorCommandStrategy
181+
private class TestStrategy : DelegatingCommandStrategy
182182
{
183183
private readonly Action _testAction;
184184

src/DynamicMvvm/Command/DynamicCommandBuilder.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public DynamicCommandBuilder(string name, IDynamicCommandStrategy baseStrategy,
4040
public IDynamicCommandStrategy BaseStrategy { get; }
4141

4242
/// <inheritdoc/>
43-
public IList<DecoratorCommandStrategy> Strategies { get; set; } = new List<DecoratorCommandStrategy>();
43+
public IList<DelegatingCommandStrategy> Strategies { get; set; } = new List<DelegatingCommandStrategy>();
4444

4545
/// <inheritdoc/>
4646
public IDynamicCommand Build()
@@ -56,7 +56,7 @@ public IDynamicCommand Build()
5656
return _command;
5757
}
5858

59-
private static IDynamicCommandStrategy GetStrategy(IDynamicCommandStrategy baseStrategy, IList<DecoratorCommandStrategy> delegatingStrategies)
59+
private static IDynamicCommandStrategy GetStrategy(IDynamicCommandStrategy baseStrategy, IList<DelegatingCommandStrategy> delegatingStrategies)
6060
{
6161
var strategy = baseStrategy;
6262

src/DynamicMvvm/Command/Strategies/BackgroundCommandStrategy.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ public static IDynamicCommandBuilder OnBackgroundThread(this IDynamicCommandBuil
1818
}
1919

2020
/// <summary>
21-
/// This <see cref="DecoratorCommandStrategy"/> will execute the command on a background thread.
21+
/// This <see cref="DelegatingCommandStrategy"/> will execute the command on a background thread.
2222
/// </summary>
23-
public class BackgroundCommandStrategy : DecoratorCommandStrategy
23+
public class BackgroundCommandStrategy : DelegatingCommandStrategy
2424
{
2525
/// <summary>
2626
/// Initializes a new instance of the <see cref="BackgroundCommandStrategy"/> class.

src/DynamicMvvm/Command/Strategies/CanExecuteCommandStrategy.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ public static IDynamicCommandBuilder WithCanExecute(this IDynamicCommandBuilder
1919
}
2020

2121
/// <summary>
22-
/// This <see cref="DecoratorCommandStrategy"/> will attach
22+
/// This <see cref="DelegatingCommandStrategy"/> will attach
2323
/// its <see cref="ICommand.CanExecute(object)"/> to the value of a <see cref="IDynamicProperty"/>.
2424
/// </summary>
25-
public class CanExecuteCommandStrategy : DecoratorCommandStrategy
25+
public class CanExecuteCommandStrategy : DelegatingCommandStrategy
2626
{
2727
private readonly IDynamicProperty<bool> _canExecute;
2828

src/DynamicMvvm/Command/Strategies/CancelPreviousCommandStrategy.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ public static IDynamicCommandBuilder CancelPrevious(this IDynamicCommandBuilder
1818
}
1919

2020
/// <summary>
21-
/// This <see cref="DecoratorCommandStrategy"/> will cancel the previous command execution when executing the command.
21+
/// This <see cref="DelegatingCommandStrategy"/> will cancel the previous command execution when executing the command.
2222
/// </summary>
23-
public class CancelPreviousCommandStrategy : DecoratorCommandStrategy
23+
public class CancelPreviousCommandStrategy : DelegatingCommandStrategy
2424
{
2525
private CancellationTokenSource _cancellationTokenSource;
2626

src/DynamicMvvm/Command/Strategies/DisableWhileExecutingCommandStrategy.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ public static IDynamicCommandBuilder DisableWhileExecuting(this IDynamicCommandB
1818
}
1919

2020
/// <summary>
21-
/// This <see cref="DecoratorCommandStrategy"/> will disable the command while it's executing.
21+
/// This <see cref="DelegatingCommandStrategy"/> will disable the command while it's executing.
2222
/// </summary>
23-
public class DisableWhileExecutingCommandStrategy : DecoratorCommandStrategy
23+
public class DisableWhileExecutingCommandStrategy : DelegatingCommandStrategy
2424
{
2525
public int _isExecuting;
2626

src/DynamicMvvm/Command/Strategies/ErrorHandlerCommandStrategy.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ public static IDynamicCommandBuilder CatchErrors(this IDynamicCommandBuilder bui
2828
}
2929

3030
/// <summary>
31-
/// This <see cref="DecoratorCommandStrategy"/> will catch any exception
31+
/// This <see cref="DelegatingCommandStrategy"/> will catch any exception
3232
/// that may be thrown during its execution and delegate the exception to an error handler.
3333
/// </summary>
34-
public class ErrorHandlerCommandStrategy : DecoratorCommandStrategy
34+
public class ErrorHandlerCommandStrategy : DelegatingCommandStrategy
3535
{
3636
private readonly IDynamicCommandErrorHandler _errorHandler;
3737

src/DynamicMvvm/Command/Strategies/LockCommandStrategy.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ public static IDynamicCommandBuilder Locked(this IDynamicCommandBuilder builder)
1818
}
1919

2020
/// <summary>
21-
/// This <see cref="DecoratorCommandStrategy"/> will lock the command execution.
21+
/// This <see cref="DelegatingCommandStrategy"/> will lock the command execution.
2222
/// </summary>
23-
public class LockCommandStrategy : DecoratorCommandStrategy
23+
public class LockCommandStrategy : DelegatingCommandStrategy
2424
{
2525
private readonly SemaphoreSlim _semaphore = new SemaphoreSlim(1, 1);
2626

src/DynamicMvvm/Command/Strategies/LoggerCommandStrategy.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ public static IDynamicCommandBuilder WithLogs(this IDynamicCommandBuilder builde
2020
}
2121

2222
/// <summary>
23-
/// This <see cref="DecoratorCommandStrategy"/> will log the execution of the command.
23+
/// This <see cref="DelegatingCommandStrategy"/> will log the execution of the command.
2424
/// </summary>
25-
public class LoggerCommandStrategy : DecoratorCommandStrategy
25+
public class LoggerCommandStrategy : DelegatingCommandStrategy
2626
{
2727
private readonly ILogger _logger;
2828

src/DynamicMvvm/Command/Strategies/RaiseCanExecuteOnDispatcherCommandStrategy.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Chinook.DynamicMvvm
99
/// <summary>
1010
/// This <see cref="IDynamicCommandStrategy"/> ensures that the <see cref="CanExecuteChanged"/> event is raised using <see cref="IDispatcher.ExecuteOnDispatcher(CancellationToken, Action)"/>.
1111
/// </summary>
12-
public class RaiseCanExecuteOnDispatcherCommandStrategy : DecoratorCommandStrategy
12+
public class RaiseCanExecuteOnDispatcherCommandStrategy : DelegatingCommandStrategy
1313
{
1414
private readonly WeakReference<IViewModel> _viewModel;
1515
private readonly CancellationTokenSource _cts = new CancellationTokenSource();

src/DynamicMvvm/Command/Strategies/SkipWhileExecutingCommandStrategy.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ public static IDynamicCommandBuilder SkipWhileExecuting(this IDynamicCommandBuil
1919
}
2020

2121
/// <summary>
22-
/// This <see cref="DecoratorCommandStrategy"/> will skip executions if the command is already executing.
22+
/// This <see cref="DelegatingCommandStrategy"/> will skip executions if the command is already executing.
2323
/// </summary>
24-
public class SkipWhileExecutingCommandStrategy : DecoratorCommandStrategy
24+
public class SkipWhileExecutingCommandStrategy : DelegatingCommandStrategy
2525
{
2626
public int _isExecuting;
2727

0 commit comments

Comments
 (0)