本文整理汇总了C#中ArgumentList.TryGetByte方法的典型用法代码示例。如果您正苦于以下问题:C# ArgumentList.TryGetByte方法的具体用法?C# ArgumentList.TryGetByte怎么用?C# ArgumentList.TryGetByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArgumentList
的用法示例。
在下文中一共展示了ArgumentList.TryGetByte方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GroupPermission
void GroupPermission(ISender sender, ArgumentList args)
{
if (!Storage.IsAvailable)
throw new CommandError("No permissions plugin or data plugin is attached");
int a = 0;
string groupName;
bool applyToGuests;
string parent, prefix, suffix;
byte r = 0, g = 0, b = 0;
var cmd = args.GetString(a++);
switch (cmd)
{
case "add":
//group add "Guest" <ApplyToGuests> <Parent> <R> <G> <B> <Prefix> <Suffix>
if (!args.TryGetString(a++, out groupName))
throw new CommandError("Expected group name after [" + cmd + "]");
args.TryGetBool(a++, out applyToGuests);
args.TryGetString(a++, out parent);
if (!args.TryGetByte(a++, out r))
r = 255;
if (!args.TryGetByte(a++, out g))
g = 255;
if (!args.TryGetByte(a++, out b))
b = 255;
args.TryGetString(a++, out prefix);
args.TryGetString(a++, out suffix);
if (Storage.FindGroup(groupName) != null)
throw new CommandError("There is already a group defined as " + groupName);
if (Storage.AddOrUpdateGroup(groupName, applyToGuests, parent, r, g, b, prefix, suffix) != null)
{
sender.Message("Successfully created group " + groupName, Color.Green);
}
else
{
sender.Message("Failed to create group " + groupName, Color.Red);
}
break;
case "remove":
//group remove "Guest
if (!args.TryGetString(a++, out groupName))
throw new CommandError("Expected group name after [" + cmd + "]");
if (Storage.FindGroup(groupName) == null)
throw new CommandError("Group does not exist: " + groupName);
if (Storage.RemoveGroup(groupName))
{
sender.Message("Successfully removed group " + groupName, Color.Green);
}
else
{
sender.Message("Failed to remove group " + groupName, Color.Red);
}
break;
case "update":
//group update "Guest" <ApplyToGuests> <Parent> <R> <G> <B> <Prefix> <Suffix>
if (!args.TryGetString(a++, out groupName))
throw new CommandError("Expected group name after [" + cmd + "]");
args.TryGetBool(a++, out applyToGuests);
args.TryGetString(a++, out parent);
if (!args.TryGetByte(a++, out r))
r = 255;
if (!args.TryGetByte(a++, out g))
g = 255;
if (!args.TryGetByte(a++, out b))
b = 255;
args.TryGetString(a++, out prefix);
args.TryGetString(a++, out suffix);
if (Storage.FindGroup(groupName) == null)
throw new CommandError("This is no group defined as " + groupName);
if (Storage.AddOrUpdateGroup(groupName, applyToGuests, parent, r, g, b, prefix, suffix) != null)
{
sender.Message("Successfully updated group " + groupName, Color.Green);
}
else
{
sender.Message("Failed to update group " + groupName, Color.Red);
}
break;
case "addnode":
//group addnode "Guest" "tdsm.help" <deny>
if (!args.TryGetString(a++, out groupName))
throw new CommandError("Expected group name after [" + cmd + "]");
string addNode;
if (!args.TryGetString(a++, out addNode))
//.........这里部分代码省略.........