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
RegexCaptureGroups
获取通配符模式捕获的正则分组。
public readonly string[]? RegexCaptureGroups { get; }
Property Value
- string[]
Text
获取命令搜索的输入文本。
public readonly string? Text { get; }
Property Value
Methods
FromError(IResult)
初始化一个新的 SearchResult<T>,带有指定结果,是否成功取决于 Error 和 ErrorReason。
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>,以及类型为
Exception
的 InteractionCommandError 和异常消息作为原因。
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
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.