Class PreconditionAttribute
Requires the module or class to pass the specified precondition before execution can begin.
[AttributeUsage(AttributeTargets.Class|AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public abstract class PreconditionAttribute : Attribute
- Inheritance
-
objectAttributePreconditionAttribute
- Derived
Properties
ErrorMessage
When overridden in a derived class, uses the supplied string as the error message if the precondition doesn't pass. Setting this for a class that doesn't override this property is a no-op.
public virtual string ErrorMessage { get; set; }
Property Value
Group
Specifies a group that this precondition belongs to.
public string Group { get; set; }
Property Value
Remarks
PreconditionAttribute of the same group require only one of the preconditions to pass in order to be successful (A || B). Specifying Group = null or not at all will require all preconditions to pass, just like normal (A && B).
Methods
CheckPermissionsAsync(ICommandContext, CommandInfo, IServiceProvider)
Checks if the command has the sufficient permission to be executed.
public abstract Task<PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
Parameters
contextICommandContextThe context of the command.
commandCommandInfoThe command being executed.
servicesIServiceProviderThe service collection used for dependency injection.