Files
2026-03-04 09:37:33 +08:00

48 lines
1.1 KiB
C#

using System;
namespace DebuggingEssentials
{
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field)]
public class ConsoleCommand : Attribute
{
public string alias = string.Empty;
public string command = string.Empty;
public string description = string.Empty;
public AccessLevel accessLevel = AccessLevel.Admin;
public ConsoleCommand(AccessLevel accessLevel = AccessLevel.Admin)
{
this.accessLevel = accessLevel;
}
public ConsoleCommand(string command, string description = "", AccessLevel accessLevel = AccessLevel.Admin)
{
int num = command.LastIndexOf('.');
if (num != -1)
{
alias = command.Substring(0, num).Trim('.', ' ');
command = command.Substring(num + 1);
}
this.command = command;
this.description = description;
this.accessLevel = accessLevel;
}
public bool HasAccess(AccessLevel accessLevel)
{
if (accessLevel == AccessLevel.Free && this.accessLevel != AccessLevel.Free)
{
return false;
}
if (accessLevel == AccessLevel.Special && this.accessLevel == AccessLevel.Admin)
{
return false;
}
return true;
}
}
}