コード例 #1
0
ファイル: Parser.cs プロジェクト: UtopleMan/KingpinNet
 private bool IsCommand(string arg, IEnumerable <CommandItem> commands, out CommandItem commandFound)
 {
     commandFound = null;
     foreach (var command in commands)
     {
         if (arg.ToLower() == command.Name.ToLower())
         {
             commandFound = command;
             return(true);
         }
     }
     return(false);
 }
コード例 #2
0
 public void Generate(CommandItem command, TextWriter output, string liquidTemplateText)
 {
     try
     {
         var template        = Template.Parse(liquidTemplateText);
         var applicationDrop = ToDrop(_application);
         var commandDrop     = ToDrop(command);
         var result          = template.Render(Hash.FromAnonymousObject(new { application = applicationDrop, command = commandDrop }));
         result = result.Replace(Environment.NewLine, "").Replace(NewLine, Environment.NewLine);
         output.Write(result);
     }
     catch (DotLiquid.Exceptions.SyntaxException exception)
     {
         console.Out.WriteLine($"Syntax error in template [{liquidTemplateText}]: {exception.Message}");
     }
     catch (Exception exception)
     {
         console.Out.WriteLine(exception.ToString());
     }
 }
コード例 #3
0
 private ILiquidizable ToDrop(CommandItem command)
 {
     return(new CommandDrop(command));
 }
コード例 #4
0
 public CommandDrop(string fullCommand, CommandItem x)
 {
     this.fullCommand = fullCommand;
     this.x           = x;
 }
コード例 #5
0
 public CommandDrop(CommandItem x)
 {
     this.fullCommand = x.Name;
     this.x           = x;
 }
コード例 #6
0
 internal void AddCommand(CommandItem result)
 {
     _commands.Add(result);
 }