本文整理汇总了C#中CommandParser类的典型用法代码示例。如果您正苦于以下问题:C# CommandParser类的具体用法?C# CommandParser怎么用?C# CommandParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommandParser类属于命名空间,在下文中一共展示了CommandParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CommandParser
string ISyncWork.Run(IWorkContext context)
{
var command = new CommandParser(context.Command).Parse();
var route = new CommandRouteInterpretter(command).GetRoute();
context.CommandInterpretter.AddSyncRoute(route);
return "";
}
示例2: Main
static void Main(string[] args)
{
var commandParser = new CommandParser();
Console.WriteLine("Hello World!");
Console.ReadKey();
}
示例3: Create
public override void Create(CommandParser Parser)
{
Core.StandardMessage("version", "Build: RMUD Hadad <s0>");
Core.StandardMessage("commit", "Commit: <s0>");
Core.StandardMessage("no commit", "Commit version not found.");
Parser.AddCommand(
Or(
KeyWord("VERSION"),
KeyWord("VER")))
.Manual("Displays the server version currently running.")
.ProceduralRule((match, actor) =>
{
var buildVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
MudObject.SendMessage(actor, "@version", buildVersion);
if (System.IO.File.Exists("version.txt"))
MudObject.SendMessage(actor, "@commit", System.IO.File.ReadAllText("version.txt"));
else
MudObject.SendMessage(actor, "@no commit");
foreach (var module in Core.IntegratedModules)
MudObject.SendMessage(actor, module.Info.Description);
return PerformResult.Continue;
});
}
示例4: TestParseMultiply
public void TestParseMultiply()
{
var commandParser = new CommandParser();
string testInput = "2*8";
var result = commandParser.Parse(testInput);
Assert.AreEqual(16, result);
}
示例5: TestParseSubtract
public void TestParseSubtract()
{
var commandParser = new CommandParser();
string testInput = "2-6";
var result = commandParser.Parse(testInput);
Assert.AreEqual(-4, result);
}
示例6: TestParseDivde
public void TestParseDivde()
{
var commandParser = new CommandParser();
string testInput = "8/2";
var result = commandParser.Parse(testInput);
Assert.AreEqual(4, result);
}
示例7: TestParseMod
public void TestParseMod()
{
var commandParser = new CommandParser();
string testInput = "8%3";
var result = commandParser.Parse(testInput);
Assert.AreEqual(2, result);
}
示例8: TestParseAdd
public void TestParseAdd()
{
var commandParser = new CommandParser();
string testInput = "2+6";
var result = commandParser.Parse(testInput);
Assert.AreEqual(8, result);
}
示例9: doCommand
///<summary>
///This gets the users message and passes it on to everyone currently
///playing.
///</summary>
///<param name="p">The player who invoked the command.</param>
///<param name="cp">The options the player sent along.</param>
public override void doCommand(Player p, CommandParser cp)
{
string you = "You chat: {x{o{y\'{x{o{b" + cp.Arguments + "{x{o{y\'{x\n\r";
string everyone = "\n\r" + p.Name + " chats: {o{y\'{x{o{b" + cp.Arguments + "{x{o{y\'{x\n\r";
Mud.mudSuroden.writeAll(p, everyone, you);
}
示例10: Create
public override void Create(CommandParser Parser)
{
Parser.AddCommand(
new KeyWord("LOOK", false),
new LookProcessor(),
"Look around at your suroundings.");
}
示例11: HandleAddBlackListCmd
private void HandleAddBlackListCmd(CommandParser.Command param)
{
ulong gUID = 0uL;
ulong.TryParse(param.GetParam(1), out gUID);
MC2S_AddBlackList mC2S_AddBlackList = new MC2S_AddBlackList();
mC2S_AddBlackList.GUID = gUID;
Globals.Instance.CliSession.Send(315, mC2S_AddBlackList);
}
示例12: Parse_EmptyCommand_ShouldHaveNoTokens
public void Parse_EmptyCommand_ShouldHaveNoTokens()
{
CommandParser parser = new CommandParser();
var tokens = parser.Parse(string.Empty).Tokens.ToArray();
Assert.IsTrue(tokens.Length == 0);
}
示例13: cmdParser_HandlesNegativeNumbers
public void cmdParser_HandlesNegativeNumbers()
{
FakeDeveloperConsole console = new FakeDeveloperConsole();
CommandParser parser = new CommandParser("-12", console);
CommandToken token = parser.Tokens[0];
Assert.AreEqual(CommandTokenKind.Number, token.Kind);
}
示例14: Main
public static void Main()
{
var reader = new ConsoleReader();
var writer = new ConsoleWriter();
var commandParser = new CommandParser();
Engine.Start(reader, writer, commandParser);
}
示例15: cmdParser_HandlesCodeBlock
public void cmdParser_HandlesCodeBlock()
{
FakeDeveloperConsole console = new FakeDeveloperConsole();
CommandParser parser = new CommandParser("{Test()}", console);
CommandToken token = parser.Tokens[0];
Assert.AreEqual(CommandTokenKind.CodeBlock, token.Kind);
}