AlinSpace.Commands
6.0.5
Prefix Reserved
See the version list below for details.
dotnet add package AlinSpace.Commands --version 6.0.5
NuGet\Install-Package AlinSpace.Commands -Version 6.0.5
<PackageReference Include="AlinSpace.Commands" Version="6.0.5" />
paket add AlinSpace.Commands --version 6.0.5
#r "nuget: AlinSpace.Commands, 6.0.5"
// Install AlinSpace.Commands as a Cake Addin #addin nuget:?package=AlinSpace.Commands&version=6.0.5 // Install AlinSpace.Commands as a Cake Tool #tool nuget:?package=AlinSpace.Commands&version=6.0.5
<img src="https://github.com/onixion/AlinSpace.Commands/blob/main/Assets/Icon.png" width="200" height="200">
AlinSpace.Commands
A simple library offering asynchronous command and powerful command manager.
The AlinSpace.Command.ICommand interface is very similar to the System.Windows.Input.ICommand interface, but they are not the same. The AlinSpace.Command.ICommand interface is a fully asynchronous command interface, whereas System.Windows.Input.ICommand is not.
Examples - AlinSpace.Command.Command
This is the AlinSpace.Command.Command:
var command = Command
.New()
.OnCanChange(_ => canExecute)
.OnExecuteAsync(ExecuteSomethingAsync);
var genericCommand = Command
.New<int>()
.OnCanChange(_ => canExecute)
.OnExecuteAsync(ExecuteSomethingWithIntAsync);
Examples - AlinSpace.Command.AbstractCommand
This is the AlinSpace.Command.AbstractCommand:
public class MyCommand : AbstractCommand
{
...
public async Task ExecuteAsync(object parameter = null)
{
await DoSomethingAsync(parameter);
}
...
}
public class MyGenericCommand<int> : AbstractCommand
{
...
public async Task ExecuteAsync(int parameter = null)
{
await DoSomethingWithIntAsync(parameter);
}
...
}
Examples - AlinSpace.Command.Manager
The AlinSpace.Command.Manager allows to create command groups. Command groups dictate the availability of command execution. Commands are registered to one command group. When registering a ICommand to a group, it will return an ICommand instance. This instance can be passed to the view that consumes the command. The command manager will hide all the logic for locking, unlocking, and notifying commands for you. Additionally, each registered Async command can also add instance-specific logic for CanExecute.
Here are some examples:
Manager
.New()
.LockAll(e =>
{
SaveCommand = e.Register(SaveCommand);
DeleteCommand = e.Register(DeleteCommand);
});
Each command group defines a group lock behavior. This behavior defines how the group will affect other groups when it gets locked. On default the command group lock is set to LockAllGroups, meaning all groups will be locked when a command is executed from this group. When an group is locked by at least one group, all commands registered to this group will not be able to execute until released by all groups.
These are the currently supported group lock behaviors:
- LockAllGroups: Locks all groups when executing a command registered to this group.
- LockOtherGroups: Locks all other groups when executing a command registered to this group.
- LockThisGroup: Locks this group when executing a command registered to this group.
In the following example, SaveCommand and DeleteCommand will lock all commands registered to the command manager when executed. However, the SearchCommand will lock all commands registered to the command manager except itself when executed.
Manager
.New()
.LockAll(eg =>
{
SaveCommand = eg.Register(SaveCommand);
DeleteCommand = eg.Register(DeleteCommand);
})
.LockAllOthers(eg =>
{
SearchCommand = eg.Register(SearchCommand);
});
An important detail is that locking requirements can overlap. Here is an example: The Block10Command will do 10 seconds of work. The Block20Command will do 20 seconds of work.
Manager
.New()
.LockThis(eg => Block10Command = eg.Register(Block10Command))
.LockAll(eg => Block20Command = eg.Register(Block20Command));
When you press the Block10Command the command manager will lock the Block10Command for 10 seconds. If you wait 5 seconds and then execute the Block20Command command, all commands will be locked for another 20 seconds. After waiting for 5 seconds the Block10Command will be done and unlock its group, but because the other command group still blocks all groups for another 15 seconds, Block10Command will stay blocked for 15 seconds. Block10Command and Block20Command will both be unlocked at the same time.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.