Ejemplo n.º 1
0
 public override void Visit(Command command)
 {
     PropertyInfo[] properties = command.GetType().GetProperties();
     foreach (PropertyInfo property in properties)
     {
         GinResultAttribute attr = (GinResultAttribute)property.GetCustomAttributes(typeof(GinResultAttribute), true).FirstOrDefault();
         if (attr != null)
         {
             if (attr.Result != null)
             {
                 string name = (string)property.GetValue(command, null);
                 if (!String.IsNullOrEmpty(name))
                 {
                     _list.Add(new ResultInfo()
                     {
                         Type        = attr.Result,
                         Name        = name,
                         Description = attr.Description
                     });
                 }
             }
             else if (_findRecursive && attr.Kind == CommandResultKind.Dynamic)
             {
                 string name = (string)property.GetValue(command, null);
                 if (name == null)
                 {
                     continue;
                 }
                 ResultInfo find = _firstRunResults.FirstOrDefault(r => ExecutionContext.GetPercentedKey(r.Name) == name);
                 if (find == null)
                 {
                     continue;
                 }
                 List <ParsedResult> members = CMParseResult.GetObjectValueMembers(find.Type, null, name);
                 foreach (var member in members)
                 {
                     if (!String.IsNullOrEmpty(member.Name))
                     {
                         _list.Add(new ResultInfo()
                         {
                             Type        = member.Type,
                             Name        = member.Name,
                             Description = member.Description
                         });
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
        public void ParseObjectNonParsedTest()
        {
            CMParseResult cmd =
                new CMParseResult
                {
                    ArgumentName = "inputValue"
                };
            NonParsedResult.Argument2 = "arg2";
            NonParsedResult inp = new NonParsedResult
                                      {
                                          Argument1 = "arg1"
                                      };
            _context.SaveResult("inputValue", inp);
            cmd.Do(_context);

            Assert.AreEqual("arg1", _context.GetResult("inputValue.Argument1"));
            Assert.AreEqual(null, _context.GetResult("inputValue.Argument2"));
        }
Ejemplo n.º 3
0
        public void ParseObjectFieldsTest()
        {
            CMParseResult cmd =
                new CMParseResult
                {
                    ArgumentName = "inputValue"
                };
            _context.SaveResult("inputValue",
                                new FieldsResult
                                {
                                    Argument1 = "arg1",
                                    Argument2 = "arg2"
                                });
            cmd.Do(_context);

            Assert.AreEqual("arg1", _context.GetResult("inputValue.Argument1"));
            Assert.AreEqual("arg2", _context.GetResult("inputValue.Argument2"));
        }