From 535793740bf31eebd83503a48a0cd286135cd623 Mon Sep 17 00:00:00 2001 From: Kristoffer Tungland Date: Mon, 4 Nov 2024 09:21:37 +0100 Subject: [PATCH] Rename Command to FluentCommand and update references Replaced Command and Command with FluentCommand and FluentCommand across the project. Updated README.md, test cases, and example code to reflect the new naming convention. Incremented project version to 0.0.2. Added new readme reference to the NuGet package specification. Introduced MVVMFluent namespace with IFluentCommand interface and FluentCommand classes. --- README.md | 38 ++++++------ src/MVVMFluent.Demo/MainViewModel.cs | 4 +- .../ViewModelBaseCommandTests.cs | 38 ++++++------ .../ViewModelBaseGenericsCommandTests.cs | 16 +++-- .../ViewModelBasePropertiesTests.cs | 4 +- .../CommandValidationExtensions.cs | 4 +- src/MVVMFluent.WPF/MVVMFluent.WPF.csproj | 2 +- src/MVVMFluent.WPF/MVVMFluent.WPF.nuspec | 3 +- src/MVVMFluent.WPF/ValidationViewModelBase.cs | 4 +- src/MVVMFluent/AsyncCommand.cs | 22 +++---- .../{Command.cs => FluentCommand.cs} | 62 +++++++++---------- src/MVVMFluent/FluentSetterViewModelBase.cs | 40 ++++++------ src/MVVMFluent/MVVMFluent.csproj | 2 +- src/MVVMFluent/MVVMFluent.nuspec | 2 + src/MVVMFluent/ViewModelBase.cs | 4 +- 15 files changed, 127 insertions(+), 118 deletions(-) rename src/MVVMFluent/{Command.cs => FluentCommand.cs} (78%) diff --git a/README.md b/README.md index 3429e89..e9c59c8 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,9 @@ MVVMFluent is a lightweight, source-only .NET library designed to simplify the M ## Features - Fluent Property Setters: Easily chain property setters with `Changed`, `Changing`, command reevaluation, and property change notifications. -- Fluent Command Setup: Define commands with `Do` methods and conditional execution via `If`. -- Generic `Command`: Define commands with parameterized actions using a strongly-typed approach. -- Implements `ICommand`: Both `Command` and `Command` implement the `ICommand` interface, enabling full compatibility with WPF and other MVVM frameworks. +- Fluent FluentCommand Setup: Define commands with `Do` methods and conditional execution via `If`. +- Generic `FluentCommand`: Define commands with parameterized actions using a strongly-typed approach. +- Implements `ICommand`: Both `FluentCommand` and `FluentCommand` implement the `ICommand` interface, enabling full compatibility with WPF and other MVVM frameworks. - Source-Only Package: Integrates directly into your project as source code, minimizing dependencies. - Global Namespace Integration: Fully qualified `global::` namespaces for all system types and dependencies. - Disposal Management: Manage and clean up resources with built-in `Dispose` functionality. @@ -51,13 +51,13 @@ public class MyViewModel : ViewModelBase ``` Here, the `Set` method is used directly to assign the new value to the property without needing any additional configuration like `Changing` or `Changed`. -### Fluent `Command` Setup +### Fluent `FluentCommand` Setup Commands in MVVMFluent can be easily defined with `Do` methods, and you can add conditional execution using `If`. ```csharp public class MyViewModel : ViewModelBase { - public Command SaveCommand => Do(Save) + public FluentCommand SaveCommand => Do(Save) .If(CanSave); private void Save() @@ -69,13 +69,13 @@ public class MyViewModel : ViewModelBase } ``` -### Using `Command` for Generic Commands -In cases where you need commands that accept a parameter, you can use the generic `Command`. Both `Command` and `Command` implement the `ICommand` interface, making them compatible with WPF or any other MVVM framework that supports `ICommand`. +### Using `FluentCommand` for Generic Commands +In cases where you need commands that accept a parameter, you can use the generic `FluentCommand`. Both `FluentCommand` and `FluentCommand` implement the `ICommand` interface, making them compatible with WPF or any other MVVM framework that supports `ICommand`. ```csharp public class MyViewModel : ViewModelBase { - public Command SaveWithMessageCommand => Do(message => Save(message)) + public FluentCommand SaveWithMessageCommand => Do(message => Save(message)) .If(message => !string.IsNullOrEmpty(message)); private void Save(string message) @@ -85,7 +85,7 @@ public class MyViewModel : ViewModelBase } } ``` -This example demonstrates how `Command` can be used to handle parameterized commands with strongly-typed arguments. +This example demonstrates how `FluentCommand` can be used to handle parameterized commands with strongly-typed arguments. ### Using `Notify(nameof(...))` for Property Change Notifications You can also notify multiple properties when setting a value. This is useful when other properties are derived from or depend on the value being set. @@ -129,7 +129,7 @@ public class MyViewModel : ViewModelBase ``` In this example, if the `Counter` property hasn’t been set before, the Get(10) will return 10 as the default value. -### Asynchronous Command (`AsyncCommand`) +### Asynchronous FluentCommand (`AsyncCommand`) The AsyncCommand in the MVVMFluent library is designed to simplify asynchronous command execution with built-in support for cancellation, progress reporting, and exception handling. It allows you to execute long-running tasks without blocking the UI thread, while maintaining full control over the command's lifecycle. **Key Features:** @@ -168,14 +168,14 @@ public bool CanLoad { get => Get(true); set => Set(value); } In XAML: ```xml -