Exemple #1
0
 public virtual bool CanExecute(InterpreterReadToken token)
 {
     if ((!string.IsNullOrEmpty(CommandNamespace) || !string.IsNullOrEmpty(token.Namespace)) &&
         CommandNamespace != token.Namespace)
     {
         return(false);
     }
     if (string.IsNullOrEmpty(token.Command))
     {
         throw new InvalidOperationException("Null command in token.");
     }
     if (!string.IsNullOrEmpty(Alias) && Alias.Equals($"{token.Identifier}{token.Command}", StringComparison.OrdinalIgnoreCase))
     {
         return(true);
     }
     return(Name.Equals($"{token.Identifier}{token.Command}", StringComparison.OrdinalIgnoreCase));
 }
 protected bool IsCommand(string value, out InterpreterReadToken token)
 {
     foreach (var identifier in Options.CommandIdentifier)
     {
         if (value.StartsWith(identifier))
         {
             string restCommand = value.Replace(identifier, string.Empty);
             string commandNamespace, parameter;
             GrabNamespace(restCommand, out commandNamespace, out restCommand);
             GrabParamenter(restCommand, out parameter, out restCommand);
             var command = restCommand;
             token = new InterpreterReadToken(identifier, commandNamespace, command, parameter, null);
             return(true);
         }
     }
     token = null;
     return(false);
 }
Exemple #3
0
 public ExecutionData(Command command, string parameter, InterpreterReadToken readerToken = null)
 {
     Command     = command;
     Parameter   = parameter;
     ReaderToken = readerToken;
 }
Exemple #4
0
 public virtual Task Execute(InterpreterReadToken token, Func <Task> next) => Execute(token.Value, next);