Ejemplo n.º 1
0
 private static object ParseTypeValue <T>(Switch opts, string typevalue, Type member_type, T member_name_or_index, object default_value, Function <Switch, T, IList <string> > itemsprovider, int namespace_id)
 {
     if (opts.creators != null && opts.creators.ContainsKey(member_type))
     {
         return(opts.creators[member_type](typevalue));
     }
     if (member_type.IsArray)
     {
         Type element_type = member_type.GetElementType();
         if (IsLiteralValue(element_type))
         {
             return(ParseArrayOfLiterals(itemsprovider(opts, member_name_or_index), element_type, member_name_or_index, null));
         }
         else
         {
             return(ParseArrayOfObjects(typevalue, element_type));
         }
     }
     if (IsLiteralValue(member_type))
     {
         return(ParseTypeLiteralValue(member_type, typevalue, default_value));
     }
     if (IsDictionary(member_type))
     {
         return(ParseDictionary(opts, member_type, member_name_or_index, default_value, namespace_id));
     }
     if (IsGenericSingleTypeParameterCollection(member_type))
     {
         Type element_type = member_type.GetGenericArguments()[0];
         if (IsLiteralValue(element_type))
         {
             return(ParseGenericCollectionOfLiterals(itemsprovider(opts, member_name_or_index), member_type, element_type, null));
         }
         else
         {
             return(ParseGenericCollectionOfObjects(typevalue, member_type, element_type));
         }
     }
     if (member_type.IsClass)
     {
         string[] subargs = SystemArgumentParser.Parse(typevalue);
         return(Switch.AsType(subargs, member_type));
     }
     throw new Exception(string.Format("The data type for {0} is not supported yet:{1}", member_name_or_index, member_type.FullName));
 }
Ejemplo n.º 2
0
 private static string[] ParseCommandLine(string line)
 {
     return(SystemArgumentParser.Parse(line));
 }
Ejemplo n.º 3
0
        public TargetType AsType <TargetType>(int index)
        {
            Function <Switch, int, IList <string> > itemprovider = (args, arg_index) => new List <string>(SystemArgumentParser.Parse(args[arg_index]));

            return((TargetType)ParseTypeValue(this, this[index], typeof(TargetType), index, default(TargetType), itemprovider, 1));
        }