1
0
mirror of https://github.com/oliverbooth/VpSharp synced 2024-11-22 19:58:48 +00:00

refactor: offer cls-compliant attribute ctors

This commit is contained in:
Oliver Booth 2023-05-08 16:00:00 +01:00
parent 7084fc3f4a
commit 9171872ec4
No known key found for this signature in database
GPG Key ID: 20BEB9DC87961025
3 changed files with 42 additions and 0 deletions

View File

@ -1,15 +1,29 @@
namespace VpSharp.Commands.Attributes.ExecutionChecks;
#pragma warning disable CA1019 // Define accessors for attribute arguments
/// <summary>
/// Specifies that this command can only be run by bots.
/// </summary>
public sealed class RequireAvatarNameAttribute : PreExecutionCheckAttribute
{
/// <summary>
/// Initializes a new instance of the <see cref="RequireAvatarNameAttribute" /> class.
/// </summary>
/// <param name="names">An enumerable collection of allowed user names.</param>
/// <exception cref="ArgumentNullException"><paramref name="names" /> is <see langword="null" />.</exception>
public RequireAvatarNameAttribute(IEnumerable<string> names)
{
ArgumentNullException.ThrowIfNull(names);
Names = names.ToArray();
}
/// <summary>
/// Initializes a new instance of the <see cref="RequireAvatarNameAttribute" /> class.
/// </summary>
/// <param name="names">An array of allowed user names.</param>
/// <exception cref="ArgumentNullException"><paramref name="names" /> is <see langword="null" />.</exception>
[CLSCompliant(false)]
public RequireAvatarNameAttribute(params string[] names)
{
ArgumentNullException.ThrowIfNull(names);

View File

@ -1,15 +1,29 @@
namespace VpSharp.Commands.Attributes.ExecutionChecks;
#pragma warning disable CA1019 // Define accessors for attribute arguments
/// <summary>
/// Specifies that this command can only be run by bots.
/// </summary>
public sealed class RequireUserIdAttribute : PreExecutionCheckAttribute
{
/// <summary>
/// Initializes a new instance of the <see cref="RequireUserIdAttribute" /> class.
/// </summary>
/// <param name="userIds">An enumerable collection of allowed user IDs.</param>
/// <exception cref="ArgumentNullException"><paramref name="userIds" /> is <see langword="null" />.</exception>
public RequireUserIdAttribute(IEnumerable<int> userIds)
{
ArgumentNullException.ThrowIfNull(userIds);
UserIds = userIds.ToArray();
}
/// <summary>
/// Initializes a new instance of the <see cref="RequireUserIdAttribute" /> class.
/// </summary>
/// <param name="userIds">An array of allowed user IDs.</param>
/// <exception cref="ArgumentNullException"><paramref name="userIds" /> is <see langword="null" />.</exception>
[CLSCompliant(false)]
public RequireUserIdAttribute(params int[] userIds)
{
ArgumentNullException.ThrowIfNull(userIds);

View File

@ -1,15 +1,29 @@
namespace VpSharp.Commands.Attributes.ExecutionChecks;
#pragma warning disable CA1019 // Define accessors for attribute arguments
/// <summary>
/// Specifies that this command can only be run by bots.
/// </summary>
public sealed class RequireUserNameAttribute : PreExecutionCheckAttribute
{
/// <summary>
/// Initializes a new instance of the <see cref="RequireUserNameAttribute" /> class.
/// </summary>
/// <param name="names">An enumerable collection of allowed user names.</param>
/// <exception cref="ArgumentNullException"><paramref name="names" /> is <see langword="null" />.</exception>
public RequireUserNameAttribute(IEnumerable<string> names)
{
ArgumentNullException.ThrowIfNull(names);
Names = names.ToArray();
}
/// <summary>
/// Initializes a new instance of the <see cref="RequireUserNameAttribute" /> class.
/// </summary>
/// <param name="names">An array of allowed user names.</param>
/// <exception cref="ArgumentNullException"><paramref name="names" /> is <see langword="null" />.</exception>
[CLSCompliant(false)]
public RequireUserNameAttribute(params string[] names)
{
ArgumentNullException.ThrowIfNull(names);