当前位置: 首页>>代码示例>>C#>>正文


C# ArgumentList.GetBool方法代码示例

本文整理汇总了C#中ArgumentList.GetBool方法的典型用法代码示例。如果您正苦于以下问题:C# ArgumentList.GetBool方法的具体用法?C# ArgumentList.GetBool怎么用?C# ArgumentList.GetBool使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ArgumentList的用法示例。


在下文中一共展示了ArgumentList.GetBool方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ServerList

 /// <summary>
 /// Manages the server list
 /// </summary>
 /// <param name="sender">Sending player</param>
 /// <param name="args">Arguments sent with command</param>
 public void ServerList(ISender sender, ArgumentList args)
 {
     string first;
     args.TryPopOne(out first);
     switch (first)
     {
         case "enable":
             Heartbeat.Begin(CoreBuild);
             sender.SendMessage("Heartbeat enabled to the TDSM server.");
             break;
         case "disable":
             Heartbeat.End();
             sender.SendMessage("Heartbeat disabled to the TDSM server.");
             break;
         case "public":
             Heartbeat.PublishToList = args.GetBool(1);
             sender.SendMessage("Server list is now " + (Heartbeat.PublishToList ? "public" : "private"));
             break;
         case "desc":
             string d;
             if (args.TryPopOne(out d))
             {
                 Heartbeat.ServerDescription = d;
                 sender.SendMessage("Description set to: " + Heartbeat.ServerDescription);
             }
             else sender.SendMessage("Current description: " + Heartbeat.ServerDescription);
             break;
         case "name":
             string n;
             if (args.TryPopOne(out n))
             {
                 Heartbeat.ServerName = n;
                 sender.SendMessage("Name set to: " + Heartbeat.ServerName);
             }
             else sender.SendMessage("Current name: " + Heartbeat.ServerName);
             break;
         case "domain":
             string h;
             if (args.TryPopOne(out h))
             {
                 Heartbeat.ServerDomain = h;
                 sender.SendMessage("Domain set to: " + Heartbeat.ServerDomain);
             }
             else sender.SendMessage("Current domain: " + Heartbeat.ServerDomain);
             break;
         case "?":
         case "print":
             sender.SendMessage("Heartbeat is " + (Heartbeat.Enabled ? "enabled" : "disabled"));
             sender.SendMessage("Server list " + (Heartbeat.PublishToList ? "public" : "private"));
             sender.SendMessage("Current name: " + Heartbeat.ServerName);
             sender.SendMessage("Current domain: " + Heartbeat.ServerDomain);
             sender.SendMessage("Current description: " + Heartbeat.ServerDescription);
             break;
         default:
             throw new CommandError("Not a supported serverlist command " + first);
     }
 }
开发者ID:Stickiler,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:62,代码来源:Commands.cs

示例2: ServerList

 /// <summary>
 /// Manages the server list
 /// </summary>
 /// <param name="sender">Sending player</param>
 /// <param name="args">Arguments sent with command</param>
 public void ServerList(ISender sender, ArgumentList args)
 {
     string first;
     args.TryPopOne(out first);
     switch (first)
     {
         case "enable":
             if (!Heartbeat.Enabled)
             {
                 Heartbeat.Begin(Entry.CoreBuild);
                 sender.SendMessage("Heartbeat enabled to the TDSM server.");
             }
             else
             {
                 sender.SendMessage("Heartbeat is already enabled.");
             }
             break;
         case "disable":
             if (Heartbeat.Enabled)
             {
                 Heartbeat.End();
                 sender.SendMessage("Heartbeat disabled to the TDSM server.");
             }
             else
             {
                 sender.SendMessage("Heartbeat is not enabled.");
             }
             break;
         case "public":
             Heartbeat.PublishToList = args.GetBool(0);
             if (!ConfigUpdater.IsAvailable || ConfigUpdater.Set("server-list", Heartbeat.PublishToList))
                 sender.SendMessage("Server list is now " + (Heartbeat.PublishToList ? "public" : "private"));
             else sender.Message("Failed to update visibility");
             break;
         case "desc":
             string d;
             if (args.TryPopOne(out d))
             {
                 Heartbeat.ServerDescription = d;
                 if (!ConfigUpdater.IsAvailable || ConfigUpdater.Set("server-list-desc", d))
                     sender.SendMessage("Description set to: " + Heartbeat.ServerDescription);
                 else sender.Message("Failed to update description");
             }
             else
                 sender.SendMessage("Current description: " + Heartbeat.ServerDescription);
             break;
         case "name":
             string n;
             if (args.TryPopOne(out n))
             {
                 Heartbeat.ServerName = n;
                 if (!ConfigUpdater.IsAvailable || ConfigUpdater.Set("server-list-name", n))
                     sender.SendMessage("Name set to: " + Heartbeat.ServerName);
                 else sender.Message("Failed to update name");
             }
             else
                 sender.SendMessage("Current name: " + Heartbeat.ServerName);
             break;
         case "domain":
             string h;
             if (args.TryPopOne(out h))
             {
                 Heartbeat.ServerDomain = h;
                 if (!ConfigUpdater.IsAvailable || ConfigUpdater.Set("server-list-domain", h))
                     sender.SendMessage("Domain set to: " + Heartbeat.ServerDomain);
                 else sender.Message("Failed to update domain");
             }
             else
                 sender.SendMessage("Current domain: " + Heartbeat.ServerDomain);
             break;
         case "?":
         case "print":
             sender.SendMessage("Heartbeat is " + (Heartbeat.Enabled ? "enabled" : "disabled"));
             if (Heartbeat.LastBeat.HasValue)
                 sender.SendMessage("Last beat: " + Heartbeat.LastBeat);
             else
                 sender.SendMessage("Last beat: n/a");
             sender.SendMessage("Server list is " + (Heartbeat.PublishToList ? "public" : "private"));
             sender.SendMessage("Current name: " + Heartbeat.ServerName);
             sender.SendMessage("Current domain: " + Heartbeat.ServerDomain);
             sender.SendMessage("Current description: " + Heartbeat.ServerDescription);
             break;
         default:
             throw new CommandError("Not a supported serverlist command " + first);
     }
 }
开发者ID:DeathCradle,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:91,代码来源:ServerListCommand.cs


注:本文中的ArgumentList.GetBool方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。