Records details of a Command parameter.
Inheritance: ISetting
Exemple #1
0
 private ISettingsCollection PrepareSettingsCollectionArg(Command cmd, CommandParameter param,
         Dictionary<string, object> args, StringBuilder sb)
 {
     // Attempt to create an instance of the collection class if necessary
     if(!HasObject(param.ParameterType)) {
         foreach(var step in FindPathToType(param.ParameterType, cmd)) {
             Instantiate(step, args);
         }
     }
     // Set each setting that has a value in the supplied args
     var coll = this[param.ParameterType] as ISettingsCollection;
     foreach(var setting in GetSettings(param.ParameterType)) {
         if(setting is DynamicSettingAttribute) {
             _log.Trace("Retrieving dynamic setting argument names");
             foreach(var dynset in ((IDynamicSettingsCollection)coll).DynamicSettingNames) {
                 if(args.ContainsKey(dynset)) {
                     _log.DebugFormat("Processing dynamic setting {0}", dynset);
                     coll[dynset] = ConvertSetting(args[dynset], setting);
                     LogSettingNameValue(sb, dynset, coll[dynset]);
                 }
             }
         }
         else if(args.ContainsKey(setting.Name)) {
             coll[setting.InternalName] = ConvertSetting(args[setting.Name], setting);
             LogSettingValue(sb, setting, coll[setting.InternalName]);
         }
         else if(setting.HasAlias && args.ContainsKey(setting.Alias)) {
             coll[setting.InternalName] = ConvertSetting(args[setting.Alias], setting);
             LogSettingValue(sb, setting, coll[setting.InternalName]);
         }
     }
     return coll;
 }
Exemple #2
0
        // Constructor
        public Command(Type t, MethodInfo mi, CommandAttribute attr)
        {
            this.MethodInfo = mi;
            this.Type = t;
            this.CommandAttribute = attr;

            _log.DebugFormat("Found command {0}", this.Name);

            foreach(var pi in mi.GetParameters()) {
                var param = new CommandParameter(pi);
                _log.DebugFormat("Found parameter {0}", param);
                this.Parameters.Add(param);
            }
        }