Table of Contents

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

IReadOnlyCollection<Attribute>

CommandService

获取底层命令服务。

public InteractionService CommandService { get; }

Property Value

InteractionService

MethodName

获取命令处理方法的名称。

public string MethodName { get; }

Property Value

string

Module

获取该方法所属的模块。

public ModuleInfo Module { get; }

Property Value

ModuleInfo

Name

获取命令的名称。

public string Name { get; }

Property Value

string

Parameters

获取此命令的参数集合。

public abstract IReadOnlyList<TParameter> Parameters { get; }

Property Value

IReadOnlyList<TParameter>

Preconditions

获取此命令的先决条件集合。

public IReadOnlyCollection<PreconditionAttribute> Preconditions { get; }

Property Value

IReadOnlyCollection<PreconditionAttribute>

RunMode

获取此命令的运行模式。

public RunMode RunMode { get; }

Property Value

RunMode

TreatNameAsRegex

获取命令名称是否应被视为正则表达式。

public bool TreatNameAsRegex { get; }

Property Value

bool

Methods

CheckPreconditionsAsync(IInteractionContext, IServiceProvider?)

检查执行上下文是否满足命令的先决条件要求。

public Task<PreconditionResult> CheckPreconditionsAsync(IInteractionContext context, IServiceProvider? services)

Parameters

context IInteractionContext
services IServiceProvider

Returns

Task<PreconditionResult>

ExecuteAsync(IInteractionContext, IServiceProvider?)

使用提供的上下文执行命令。

public virtual Task<IResult> ExecuteAsync(IInteractionContext context, IServiceProvider? services)

Parameters

context IInteractionContext

执行上下文。

services IServiceProvider

用于创建模块实例的依赖项。

Returns

Task<IResult>

表示执行过程的任务。任务结果包含执行结果。

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

Task<IResult>

表示异步解析操作的任务。任务结果包含解析后的参数。

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.