advanced userinterface design
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.UserInterface
|
||||
{
|
||||
public abstract class ViewHost
|
||||
{
|
||||
|
||||
protected ViewHost(
|
||||
string name,
|
||||
StateHost stateHost
|
||||
)
|
||||
{
|
||||
Name = string.IsNullOrWhiteSpace(name) ?
|
||||
throw new ArgumentException("Value cannot be null or whitespace.", nameof(name)) :
|
||||
name;
|
||||
StateHost = stateHost ?? throw new ArgumentNullException(nameof(stateHost));
|
||||
}
|
||||
|
||||
public string Name { get; }
|
||||
|
||||
protected StateHost StateHost { get; }
|
||||
|
||||
public virtual Task<CommandResult> PostAsync(
|
||||
StateChangeCommand command,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
return StateHost.PostAsync(this, command, cancellationToken);
|
||||
}
|
||||
|
||||
public virtual Task<CommandResult> PostAsync(
|
||||
ExecuteCommand command,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
return StateHost.PostAsync(this, command, cancellationToken);
|
||||
}
|
||||
|
||||
public virtual ValueTask ReceiveCommandResultAsync(
|
||||
CommandResult result,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(result);
|
||||
return ValueTask.CompletedTask;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user