49 lines
1.7 KiB
C#
49 lines
1.7 KiB
C#
#nullable enable
|
|
|
|
using System;
|
|
using Cysharp.Threading.Tasks;
|
|
using ShrinkApp;
|
|
|
|
namespace ShrinkCommand.Integration.App
|
|
{
|
|
[ShrinkAppModuleInstaller]
|
|
[Obsolete("ClassicHost compatibility only. ContextLoader projects should use ShrinkCommandAppComponent from a composition root.")]
|
|
public sealed class ShrinkCommandAppInstaller : IShrinkAppModuleInstaller
|
|
{
|
|
public string ModuleId => "shrink.command";
|
|
public int Order => -1500;
|
|
public System.Collections.Generic.IReadOnlyList<string> DependsOn => Array.Empty<string>();
|
|
|
|
public void RegisterServices(ShrinkAppContext context)
|
|
{
|
|
context.Services.Register(new ShrinkCommandAppService(ShrinkCommandRuntime.Default));
|
|
}
|
|
|
|
public UniTask InitializeAsync(ShrinkAppContext context)
|
|
{
|
|
return UniTask.CompletedTask;
|
|
}
|
|
}
|
|
|
|
public sealed class ShrinkCommandAppService
|
|
{
|
|
public ShrinkCommandAppService(ShrinkCommandService service)
|
|
{
|
|
Service = service ?? throw new ArgumentNullException(nameof(service));
|
|
}
|
|
|
|
public ShrinkCommandService Service { get; }
|
|
|
|
public UniTask<ShrinkCommandExecutionResult> ExecuteAsync(
|
|
IShrinkCommandSource source,
|
|
string rawInput,
|
|
System.Threading.CancellationToken cancellationToken = default)
|
|
=> Service.ExecuteAsync(source, rawInput, cancellationToken);
|
|
|
|
public string BuildHelp(IShrinkCommandSource? source, string? prefix = null)
|
|
=> Service.BuildHelp(source, prefix);
|
|
|
|
public System.Collections.Generic.IReadOnlyList<ShrinkCommandDescriptor> Commands => Service.Commands;
|
|
}
|
|
}
|