1
0
mirror of https://github.com/oliverbooth/VpSharp synced 2024-11-10 02:55:41 +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; namespace VpSharp.Commands.Attributes.ExecutionChecks;
#pragma warning disable CA1019 // Define accessors for attribute arguments
/// <summary> /// <summary>
/// Specifies that this command can only be run by bots. /// Specifies that this command can only be run by bots.
/// </summary> /// </summary>
public sealed class RequireAvatarNameAttribute : PreExecutionCheckAttribute 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> /// <summary>
/// Initializes a new instance of the <see cref="RequireAvatarNameAttribute" /> class. /// Initializes a new instance of the <see cref="RequireAvatarNameAttribute" /> class.
/// </summary> /// </summary>
/// <param name="names">An array of allowed user names.</param> /// <param name="names">An array of allowed user names.</param>
/// <exception cref="ArgumentNullException"><paramref name="names" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="names" /> is <see langword="null" />.</exception>
[CLSCompliant(false)]
public RequireAvatarNameAttribute(params string[] names) public RequireAvatarNameAttribute(params string[] names)
{ {
ArgumentNullException.ThrowIfNull(names); ArgumentNullException.ThrowIfNull(names);

View File

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

View File

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