Class CommandInfo<TParameter>
- Namespace
- HeyBox.Interactions
- Assembly
- HeyBox.Net.Interactions.dll
InteractionService 命令的基础信息类。
public abstract class CommandInfo<TParameter> : ICommandInfo where TParameter : class, IParameterInfo
Type Parameters
TParameter
此命令类型所用的 IParameterInfo 类型。
- Inheritance
-
CommandInfo<TParameter>
- Implements
- Derived
- Inherited Members
Properties
Attributes
获取此命令的特性集合。
public IReadOnlyCollection<Attribute> Attributes { get; }
Property Value
CommandService
获取底层命令服务。
public InteractionService CommandService { get; }
Property Value
MethodName
获取命令处理方法的名称。
public string MethodName { get; }
Property Value
Module
获取该方法所属的模块。
public ModuleInfo Module { get; }
Property Value
Name
获取命令的名称。
public string Name { get; }
Property Value
Parameters
获取此命令的参数集合。
public abstract IReadOnlyList<TParameter> Parameters { get; }
Property Value
- IReadOnlyList<TParameter>
Preconditions
获取此命令的先决条件集合。
public IReadOnlyCollection<PreconditionAttribute> Preconditions { get; }
Property Value
RunMode
获取此命令的运行模式。
public RunMode RunMode { get; }
Property Value
TreatNameAsRegex
获取命令名称是否应被视为正则表达式。
public bool TreatNameAsRegex { get; }
Property Value
Methods
CheckPreconditionsAsync(IInteractionContext, IServiceProvider?)
检查执行上下文是否满足命令的先决条件要求。
public Task<PreconditionResult> CheckPreconditionsAsync(IInteractionContext context, IServiceProvider? services)
Parameters
context
IInteractionContextservices
IServiceProvider
Returns
ExecuteAsync(IInteractionContext, IServiceProvider?)
使用提供的上下文执行命令。
public virtual Task<IResult> ExecuteAsync(IInteractionContext context, IServiceProvider? services)
Parameters
context
IInteractionContext执行上下文。
services
IServiceProvider用于创建模块实例的依赖项。
Returns
GetLogString(IInteractionContext)
获取此命令的日志字符串。
protected abstract string GetLogString(IInteractionContext context)
Parameters
context
IInteractionContext命令的上下文。
Returns
- string
此命令的日志字符串。
InvokeEventAndReturn<T>(IInteractionContext, T)
调用此命令的模块事件并返回结果。
protected Task<T> InvokeEventAndReturn<T>(IInteractionContext context, T result) where T : IResult
Parameters
context
IInteractionContext命令的上下文。
result
T命令的执行结果。
Returns
- Task<T>
命令的执行结果。
Type Parameters
T
结果的类型。
InvokeModuleEvent(IInteractionContext, IResult)
调用此命令的模块事件。
protected abstract Task InvokeModuleEvent(IInteractionContext context, IResult result)
Parameters
context
IInteractionContext命令的上下文。
result
IResult命令的执行结果。
Returns
- Task
表示异步调用操作的任务。
ParseArgumentsAsync(IInteractionContext, IServiceProvider?)
解析此命令的参数。
protected abstract Task<IResult> ParseArgumentsAsync(IInteractionContext context, IServiceProvider? services)
Parameters
context
IInteractionContext命令的上下文。
services
IServiceProvider用于依赖注入的服务集合。
Returns
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.