Class ArgumentErrorAttribute
Base attribute for all argument error attributes.
Inheritance
Namespace: TehGM.Wolfringo.Commands.Attributes
Assembly: Wolfringo.Commands.dll
Syntax
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)]
public abstract class ArgumentErrorAttribute : Attribute, IEquatable<ArgumentErrorAttribute>, IEquatable<string>
Remarks
Decorating a method parameter with this argument will allow specifying message that will be sent to the user if there's any error when building the param.
TextTemplate can have a few placeholders inside. On runtime, each of these placeholders will be replaced with an actual value. Currently supported placeholders are: ArgPlaceholder, TypePlaceholder, NamePlaceholder, MessagePlaceholder, SenderNicknamePlaceholder, SenderIdPlaceholder, BotNicknamePlaceholder, BotIdPlaceholder.
To add new placeholders, create new attributes inheriting from ConvertingErrorAttribute or MissingErrorAttribute, and override ToStringAsync(ICommandContext, String, ParameterInfo, CancellationToken) method. To preserve default placeholders, call
base.ToStringAsync() BEFORE your custom placeholders handling.
Constructors
| Improve this Doc View SourceArgumentErrorAttribute(String)
Attribute to specify message that will be sent as respone when argument error occurs.
Declaration
public ArgumentErrorAttribute(string messageTemplate)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | messageTemplate | Message that will be sent as response on error. |
Remarks
Decorating a method parameter with this argument will allow specifying message that will be sent to the user if there's any error when building the param.
TextTemplate can have a few placeholders inside. On runtime, each of these placeholders will be replaced with an actual value. Currently supported placeholders are: ArgPlaceholder, TypePlaceholder, NamePlaceholder, MessagePlaceholder, SenderNicknamePlaceholder, SenderIdPlaceholder, BotNicknamePlaceholder, BotIdPlaceholder.
To add new placeholders, create new attributes inheriting from ConvertingErrorAttribute or MissingErrorAttribute, and override ToStringAsync(ICommandContext, String, ParameterInfo, CancellationToken) method. To preserve default placeholders, call
base.ToStringAsync() BEFORE your custom placeholders handling.
Fields
| Improve this Doc View SourceArgPlaceholder
This placeholder will be replaced with argument value at runtime.
Declaration
public const string ArgPlaceholder = "{{Arg}}"
Field Value
| Type | Description |
|---|---|
| System.String |
Remarks
Decorating a method parameter with this argument will allow specifying message that will be sent to the user if there's any error when building the param.
TextTemplate can have a few placeholders inside. On runtime, each of these placeholders will be replaced with an actual value. Currently supported placeholders are: ArgPlaceholder, TypePlaceholder, NamePlaceholder, MessagePlaceholder, SenderNicknamePlaceholder, SenderIdPlaceholder, BotNicknamePlaceholder, BotIdPlaceholder.
To add new placeholders, create new attributes inheriting from ConvertingErrorAttribute or MissingErrorAttribute, and override ToStringAsync(ICommandContext, String, ParameterInfo, CancellationToken) method. To preserve default placeholders, call
base.ToStringAsync() BEFORE your custom placeholders handling.
BotIdPlaceholder
This placeholder will be replaced with ID of the bot at runtime.
Declaration
public const string BotIdPlaceholder = "{{BotID}}"
Field Value
| Type | Description |
|---|---|
| System.String |
Remarks
Decorating a method parameter with this argument will allow specifying message that will be sent to the user if there's any error when building the param.
TextTemplate can have a few placeholders inside. On runtime, each of these placeholders will be replaced with an actual value. Currently supported placeholders are: ArgPlaceholder, TypePlaceholder, NamePlaceholder, MessagePlaceholder, SenderNicknamePlaceholder, SenderIdPlaceholder, BotNicknamePlaceholder, BotIdPlaceholder.
To add new placeholders, create new attributes inheriting from ConvertingErrorAttribute or MissingErrorAttribute, and override ToStringAsync(ICommandContext, String, ParameterInfo, CancellationToken) method. To preserve default placeholders, call
base.ToStringAsync() BEFORE your custom placeholders handling.
BotNicknamePlaceholder
This placeholder will be replaced with nickname of the bot at runtime.
Declaration
public const string BotNicknamePlaceholder = "{{BotNickname}}"
Field Value
| Type | Description |
|---|---|
| System.String |
Remarks
Decorating a method parameter with this argument will allow specifying message that will be sent to the user if there's any error when building the param.
TextTemplate can have a few placeholders inside. On runtime, each of these placeholders will be replaced with an actual value. Currently supported placeholders are: ArgPlaceholder, TypePlaceholder, NamePlaceholder, MessagePlaceholder, SenderNicknamePlaceholder, SenderIdPlaceholder, BotNicknamePlaceholder, BotIdPlaceholder.
To add new placeholders, create new attributes inheriting from ConvertingErrorAttribute or MissingErrorAttribute, and override ToStringAsync(ICommandContext, String, ParameterInfo, CancellationToken) method. To preserve default placeholders, call
base.ToStringAsync() BEFORE your custom placeholders handling.
MessagePlaceholder
This placeholder will be replaced with received message contents at runtime.
Declaration
public const string MessagePlaceholder = "{{Message}}"
Field Value
| Type | Description |
|---|---|
| System.String |
Remarks
Decorating a method parameter with this argument will allow specifying message that will be sent to the user if there's any error when building the param.
TextTemplate can have a few placeholders inside. On runtime, each of these placeholders will be replaced with an actual value. Currently supported placeholders are: ArgPlaceholder, TypePlaceholder, NamePlaceholder, MessagePlaceholder, SenderNicknamePlaceholder, SenderIdPlaceholder, BotNicknamePlaceholder, BotIdPlaceholder.
To add new placeholders, create new attributes inheriting from ConvertingErrorAttribute or MissingErrorAttribute, and override ToStringAsync(ICommandContext, String, ParameterInfo, CancellationToken) method. To preserve default placeholders, call
base.ToStringAsync() BEFORE your custom placeholders handling.
NamePlaceholder
This placeholder will be replaced with parameter name at runtime.
Declaration
public const string NamePlaceholder = "{{Name}}"
Field Value
| Type | Description |
|---|---|
| System.String |
Remarks
Can be changed by using ArgumentNameAttribute.
RecipientIdPlaceholder
This placeholder will be replaced with ID of the message recipient (bot ID for PMs, group ID for group messages).
Declaration
public const string RecipientIdPlaceholder = "{{RecipientID}}"
Field Value
| Type | Description |
|---|---|
| System.String |
Remarks
Decorating a method parameter with this argument will allow specifying message that will be sent to the user if there's any error when building the param.
TextTemplate can have a few placeholders inside. On runtime, each of these placeholders will be replaced with an actual value. Currently supported placeholders are: ArgPlaceholder, TypePlaceholder, NamePlaceholder, MessagePlaceholder, SenderNicknamePlaceholder, SenderIdPlaceholder, BotNicknamePlaceholder, BotIdPlaceholder.
To add new placeholders, create new attributes inheriting from ConvertingErrorAttribute or MissingErrorAttribute, and override ToStringAsync(ICommandContext, String, ParameterInfo, CancellationToken) method. To preserve default placeholders, call
base.ToStringAsync() BEFORE your custom placeholders handling.
RecipientNamePlaceholder
This placeholder will be replaced with name of the message recipient (bot nickname for PMs, group name for group messages).
Declaration
public const string RecipientNamePlaceholder = "{{RecipientName}}"
Field Value
| Type | Description |
|---|---|
| System.String |
Remarks
Decorating a method parameter with this argument will allow specifying message that will be sent to the user if there's any error when building the param.
TextTemplate can have a few placeholders inside. On runtime, each of these placeholders will be replaced with an actual value. Currently supported placeholders are: ArgPlaceholder, TypePlaceholder, NamePlaceholder, MessagePlaceholder, SenderNicknamePlaceholder, SenderIdPlaceholder, BotNicknamePlaceholder, BotIdPlaceholder.
To add new placeholders, create new attributes inheriting from ConvertingErrorAttribute or MissingErrorAttribute, and override ToStringAsync(ICommandContext, String, ParameterInfo, CancellationToken) method. To preserve default placeholders, call
base.ToStringAsync() BEFORE your custom placeholders handling.
SenderIdPlaceholder
This placeholder will be replaced with ID of the user that sent the command at runtime.
Declaration
public const string SenderIdPlaceholder = "{{SenderID}}"
Field Value
| Type | Description |
|---|---|
| System.String |
Remarks
Decorating a method parameter with this argument will allow specifying message that will be sent to the user if there's any error when building the param.
TextTemplate can have a few placeholders inside. On runtime, each of these placeholders will be replaced with an actual value. Currently supported placeholders are: ArgPlaceholder, TypePlaceholder, NamePlaceholder, MessagePlaceholder, SenderNicknamePlaceholder, SenderIdPlaceholder, BotNicknamePlaceholder, BotIdPlaceholder.
To add new placeholders, create new attributes inheriting from ConvertingErrorAttribute or MissingErrorAttribute, and override ToStringAsync(ICommandContext, String, ParameterInfo, CancellationToken) method. To preserve default placeholders, call
base.ToStringAsync() BEFORE your custom placeholders handling.
SenderNicknamePlaceholder
This placeholder will be replaced with nickname of the user that sent the command at runtime.
Declaration
public const string SenderNicknamePlaceholder = "{{SenderNickname}}"
Field Value
| Type | Description |
|---|---|
| System.String |
Remarks
Decorating a method parameter with this argument will allow specifying message that will be sent to the user if there's any error when building the param.
TextTemplate can have a few placeholders inside. On runtime, each of these placeholders will be replaced with an actual value. Currently supported placeholders are: ArgPlaceholder, TypePlaceholder, NamePlaceholder, MessagePlaceholder, SenderNicknamePlaceholder, SenderIdPlaceholder, BotNicknamePlaceholder, BotIdPlaceholder.
To add new placeholders, create new attributes inheriting from ConvertingErrorAttribute or MissingErrorAttribute, and override ToStringAsync(ICommandContext, String, ParameterInfo, CancellationToken) method. To preserve default placeholders, call
base.ToStringAsync() BEFORE your custom placeholders handling.
TypePlaceholder
This placeholder will be replaced with parameter type at runtime.
Declaration
public const string TypePlaceholder = "{{Type}}"
Field Value
| Type | Description |
|---|---|
| System.String |
Remarks
Can be changed by using ArgumentTypeNameAttribute.
Properties
| Improve this Doc View SourceTextTemplate
Error message that will be sent as response on error.
Declaration
public string TextTemplate { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
Remarks
Decorating a method parameter with this argument will allow specifying message that will be sent to the user if there's any error when building the param.
TextTemplate can have a few placeholders inside. On runtime, each of these placeholders will be replaced with an actual value. Currently supported placeholders are: ArgPlaceholder, TypePlaceholder, NamePlaceholder, MessagePlaceholder, SenderNicknamePlaceholder, SenderIdPlaceholder, BotNicknamePlaceholder, BotIdPlaceholder.
To add new placeholders, create new attributes inheriting from ConvertingErrorAttribute or MissingErrorAttribute, and override ToStringAsync(ICommandContext, String, ParameterInfo, CancellationToken) method. To preserve default placeholders, call
base.ToStringAsync() BEFORE your custom placeholders handling.
Methods
| Improve this Doc View SourceEquals(Object)
Base attribute for all argument error attributes.
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | obj |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Overrides
Remarks
Decorating a method parameter with this argument will allow specifying message that will be sent to the user if there's any error when building the param.
TextTemplate can have a few placeholders inside. On runtime, each of these placeholders will be replaced with an actual value. Currently supported placeholders are: ArgPlaceholder, TypePlaceholder, NamePlaceholder, MessagePlaceholder, SenderNicknamePlaceholder, SenderIdPlaceholder, BotNicknamePlaceholder, BotIdPlaceholder.
To add new placeholders, create new attributes inheriting from ConvertingErrorAttribute or MissingErrorAttribute, and override ToStringAsync(ICommandContext, String, ParameterInfo, CancellationToken) method. To preserve default placeholders, call
base.ToStringAsync() BEFORE your custom placeholders handling.
Equals(String)
Base attribute for all argument error attributes.
Declaration
public bool Equals(string other)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | other |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Remarks
Decorating a method parameter with this argument will allow specifying message that will be sent to the user if there's any error when building the param.
TextTemplate can have a few placeholders inside. On runtime, each of these placeholders will be replaced with an actual value. Currently supported placeholders are: ArgPlaceholder, TypePlaceholder, NamePlaceholder, MessagePlaceholder, SenderNicknamePlaceholder, SenderIdPlaceholder, BotNicknamePlaceholder, BotIdPlaceholder.
To add new placeholders, create new attributes inheriting from ConvertingErrorAttribute or MissingErrorAttribute, and override ToStringAsync(ICommandContext, String, ParameterInfo, CancellationToken) method. To preserve default placeholders, call
base.ToStringAsync() BEFORE your custom placeholders handling.
Equals(ArgumentErrorAttribute)
Base attribute for all argument error attributes.
Declaration
public bool Equals(ArgumentErrorAttribute other)
Parameters
| Type | Name | Description |
|---|---|---|
| ArgumentErrorAttribute | other |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Remarks
Decorating a method parameter with this argument will allow specifying message that will be sent to the user if there's any error when building the param.
TextTemplate can have a few placeholders inside. On runtime, each of these placeholders will be replaced with an actual value. Currently supported placeholders are: ArgPlaceholder, TypePlaceholder, NamePlaceholder, MessagePlaceholder, SenderNicknamePlaceholder, SenderIdPlaceholder, BotNicknamePlaceholder, BotIdPlaceholder.
To add new placeholders, create new attributes inheriting from ConvertingErrorAttribute or MissingErrorAttribute, and override ToStringAsync(ICommandContext, String, ParameterInfo, CancellationToken) method. To preserve default placeholders, call
base.ToStringAsync() BEFORE your custom placeholders handling.
GetHashCode()
Base attribute for all argument error attributes.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| System.Int32 |
Overrides
Remarks
Decorating a method parameter with this argument will allow specifying message that will be sent to the user if there's any error when building the param.
TextTemplate can have a few placeholders inside. On runtime, each of these placeholders will be replaced with an actual value. Currently supported placeholders are: ArgPlaceholder, TypePlaceholder, NamePlaceholder, MessagePlaceholder, SenderNicknamePlaceholder, SenderIdPlaceholder, BotNicknamePlaceholder, BotIdPlaceholder.
To add new placeholders, create new attributes inheriting from ConvertingErrorAttribute or MissingErrorAttribute, and override ToStringAsync(ICommandContext, String, ParameterInfo, CancellationToken) method. To preserve default placeholders, call
base.ToStringAsync() BEFORE your custom placeholders handling.
ToString()
Base attribute for all argument error attributes.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| System.String |
Overrides
Remarks
Decorating a method parameter with this argument will allow specifying message that will be sent to the user if there's any error when building the param.
TextTemplate can have a few placeholders inside. On runtime, each of these placeholders will be replaced with an actual value. Currently supported placeholders are: ArgPlaceholder, TypePlaceholder, NamePlaceholder, MessagePlaceholder, SenderNicknamePlaceholder, SenderIdPlaceholder, BotNicknamePlaceholder, BotIdPlaceholder.
To add new placeholders, create new attributes inheriting from ConvertingErrorAttribute or MissingErrorAttribute, and override ToStringAsync(ICommandContext, String, ParameterInfo, CancellationToken) method. To preserve default placeholders, call
base.ToStringAsync() BEFORE your custom placeholders handling.
ToStringAsync(ICommandContext, String, ParameterInfo, CancellationToken)
Builds error response for the sent message and arg.
Declaration
public virtual async Task<string> ToStringAsync(ICommandContext context, string arg, ParameterInfo parameter, CancellationToken cancellationToken = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| ICommandContext | context | Message context that contains the argument. |
| System.String | arg | Value of argument that failed converting. |
| System.Reflection.ParameterInfo | parameter | Parameter the error is for. |
| System.Threading.CancellationToken | cancellationToken | Token to cancel any required server requests with. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<System.String> |
Remarks
Decorating a method parameter with this argument will allow specifying message that will be sent to the user if there's any error when building the param.
TextTemplate can have a few placeholders inside. On runtime, each of these placeholders will be replaced with an actual value. Currently supported placeholders are: ArgPlaceholder, TypePlaceholder, NamePlaceholder, MessagePlaceholder, SenderNicknamePlaceholder, SenderIdPlaceholder, BotNicknamePlaceholder, BotIdPlaceholder.
To add new placeholders, create new attributes inheriting from ConvertingErrorAttribute or MissingErrorAttribute, and override ToStringAsync(ICommandContext, String, ParameterInfo, CancellationToken) method. To preserve default placeholders, call
base.ToStringAsync() BEFORE your custom placeholders handling.
Operators
| Improve this Doc View SourceEquality(ArgumentErrorAttribute, ArgumentErrorAttribute)
Base attribute for all argument error attributes.
Declaration
public static bool operator ==(ArgumentErrorAttribute left, ArgumentErrorAttribute right)
Parameters
| Type | Name | Description |
|---|---|---|
| ArgumentErrorAttribute | left | |
| ArgumentErrorAttribute | right |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Remarks
Decorating a method parameter with this argument will allow specifying message that will be sent to the user if there's any error when building the param.
TextTemplate can have a few placeholders inside. On runtime, each of these placeholders will be replaced with an actual value. Currently supported placeholders are: ArgPlaceholder, TypePlaceholder, NamePlaceholder, MessagePlaceholder, SenderNicknamePlaceholder, SenderIdPlaceholder, BotNicknamePlaceholder, BotIdPlaceholder.
To add new placeholders, create new attributes inheriting from ConvertingErrorAttribute or MissingErrorAttribute, and override ToStringAsync(ICommandContext, String, ParameterInfo, CancellationToken) method. To preserve default placeholders, call
base.ToStringAsync() BEFORE your custom placeholders handling.
Inequality(ArgumentErrorAttribute, ArgumentErrorAttribute)
Base attribute for all argument error attributes.
Declaration
public static bool operator !=(ArgumentErrorAttribute left, ArgumentErrorAttribute right)
Parameters
| Type | Name | Description |
|---|---|---|
| ArgumentErrorAttribute | left | |
| ArgumentErrorAttribute | right |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Remarks
Decorating a method parameter with this argument will allow specifying message that will be sent to the user if there's any error when building the param.
TextTemplate can have a few placeholders inside. On runtime, each of these placeholders will be replaced with an actual value. Currently supported placeholders are: ArgPlaceholder, TypePlaceholder, NamePlaceholder, MessagePlaceholder, SenderNicknamePlaceholder, SenderIdPlaceholder, BotNicknamePlaceholder, BotIdPlaceholder.
To add new placeholders, create new attributes inheriting from ConvertingErrorAttribute or MissingErrorAttribute, and override ToStringAsync(ICommandContext, String, ParameterInfo, CancellationToken) method. To preserve default placeholders, call
base.ToStringAsync() BEFORE your custom placeholders handling.