Table of Contents

Struct SearchResult<T>

Namespace
HeyBox.Interactions
Assembly
HeyBox.Net.Interactions.dll

包含命令搜索的信息。

public struct SearchResult<T> : IResult where T : class, ICommandInfo

Type Parameters

T

目标命令类型。

Implements
Inherited Members

Properties

Command

获取搜索成功时找到的命令。

public readonly T? Command { get; }

Property Value

T

Error

获取操作过程中可能发生的错误类型。

public readonly InteractionCommandError? Error { get; }

Property Value

InteractionCommandError?

一个 InteractionCommandError,指示操作过程中可能发生的错误类型; 如果操作成功,则为 null

ErrorReason

获取错误原因。

public readonly string? ErrorReason { get; }

Property Value

string

包含错误原因的字符串。

IsSuccess

指示操作是否成功。

public bool IsSuccess { get; }

Property Value

bool

如果结果为正,则为 true;否则为 false

RegexCaptureGroups

获取通配符模式捕获的正则分组。

public readonly string[]? RegexCaptureGroups { get; }

Property Value

string[]

Text

获取命令搜索的输入文本。

public readonly string? Text { get; }

Property Value

string

Methods

FromError(IResult)

初始化一个新的 SearchResult<T>,带有指定结果,是否成功取决于 ErrorErrorReason

public static SearchResult<T> FromError(IResult result)

Parameters

result IResult

要继承的结果。

Returns

SearchResult<T>

一个继承了 IResult 错误类型和原因的 SearchResult<T>

FromError(Exception)

初始化一个新的 SearchResult<T>,带有指定异常,表示执行失败。

public static SearchResult<T> FromError(Exception ex)

Parameters

ex Exception

导致命令执行失败的异常。

Returns

SearchResult<T>

一个包含导致执行失败异常的 SearchResult<T>,以及类型为 ExceptionInteractionCommandError 和异常消息作为原因。

FromError(string, InteractionCommandError, string)

初始化一个新的 SearchResult<T>,带有指定的 InteractionCommandError 及原因,表示执行失败。

public static SearchResult<T> FromError(string text, InteractionCommandError error, string reason)

Parameters

text string

命令搜索的输入文本。

error InteractionCommandError

错误类型。

reason string

错误原因。

Returns

SearchResult<T>

一个包含 InteractionCommandError 和原因的 SearchResult<T>

FromSuccess(string, T, string[]?)

初始化一个新的 SearchResult<T>,无错误,表示执行成功。

public static SearchResult<T> FromSuccess(string text, T commandInfo, string[]? wildCardMatch = null)

Parameters

text string
commandInfo T
wildCardMatch string[]

Returns

SearchResult<T>

一个不包含任何错误的 SearchResult<T>

ToString()

Returns the fully qualified type name of this instance.

public override string ToString()

Returns

string

The fully qualified type name.