advanced userinterface design

This commit is contained in:
Nitload
2026-04-01 22:20:49 +08:00
parent 24498c2717
commit aa7ece4ed0
42 changed files with 2876 additions and 463 deletions
@@ -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;
}
}
}