Esempio n. 1
0
 public override bool Execute(Parser editor, string[] parameters)
 {
     bool result;
     object methodResult = null;
     if (result = this.Parameters.Length == 0 && parameters.All(parameter => parameter.IsEmpty()))
         methodResult = this.backend.Call();
     else if (result = parameters.Length == this.Parameters.Length && parameters.All(parameter => parameter.NotEmpty()) || parameters.Length - 1 == this.Parameters.Length && parameters[parameters.Length - 1].IsEmpty())
     {
         object[] p = new object[this.Parameters.Length];
         for (int i = 0; i < p.Length; i++)
             p[i] = this.Parameters[i].FromString(parameters[i]);
         methodResult = this.backend.Call(p);
     }
     if (methodResult.NotNull())
     {
         if (methodResult is bool)
         {
             if (!(bool)methodResult)
                 editor.Answer(this, "failed");
         }
         else if (methodResult is string)
             editor.Answer(this, methodResult as string);
         else
             editor.Answer(this, methodResult.ToString());
     }
     return result;
 }
Esempio n. 2
0
 public override bool RequestType(Parser editor)
 {
     Collection.List<string> results = new Collection.List<string>();
     foreach (Parameter.Abstract parameter in this.Parameters)
         results.Add(parameter.Name + " : " + parameter.Type);
     editor.TypeResponse(this, "method : (" + results.Join(" * ") + ") => " + this.ReturnType);
     return true;
 }
Esempio n. 3
0
 public static Parser Read(object root, IO.ICharacterInDevice device)
 {
     Parser result = null;
     if (device.NotNull())
     {
         result = new Parser(root, false, Cli.Terminal.Open(device, null));
         result.Read();
     }
     return result;
 }