예제 #1
0
        public override void InitAndCheck <TArgs>(MemberInfo mi, CmdArgsParser <TArgs> p, TArgs target)
        {
            if (Culture == null)
            {
                Culture = p.Culture;
            }

            Type fieldType = mi.GetFieldType();

            SetTypeAndCheck(fieldType);

            // predicates are dependent on type
            Type confType = target.GetType();

            MemberInfo[]      mis          = confType.GetFieldsAndProps();
            List <MemberInfo> miPredicates = mis.Where(x =>
            {
                Type miType = x.GetFieldType();
                return(miType.IsGenericType &&
                       miType.GetGenericTypeDefinition() == typeof(Predicate <>));
            }).ToList();
            Tuple <List <Delegate>, List <Delegate> > predicates =
                GetPredicates(miPredicates, mi.Name, target);

            ValuePredicatesForCollection = predicates?.Item1;
            ValuePredicatesForOne        = predicates?.Item2;

            // check allowed for predicateone
            // check def for predicateone, predicatecol
            CheckDefaultAndAllowedValues();
        }
예제 #2
0
        public static Res <TArgs> Parse(string[] args)
        {
            var         p   = new CmdArgsParser <TArgs>();
            Res <TArgs> res = p.ParseCommandLine(args);

            return(res);
        }
예제 #3
0
        internal void Apply <TArgs>(FileInfo value, CmdArgsParser <TArgs> p, Bindings <TArgs> bsTarget)
            where TArgs : new()
        {
            string[] fileCmdArgs = value.ReadFileAsArgs();

            Bindings <TArgs> bsSource = p.ParseCommandLineEgoist(fileCmdArgs, new Res <TArgs>());

            bsTarget.Merge(bsSource);
        }
예제 #4
0
 public Binding(bool longNameIgnoreCase, Argument argument, MemberInfo miTarget,
                Res <TArgs> target, CmdArgsParser <TArgs> cmdArgsParser)
 {
     _longNameIgnoreCase = longNameIgnoreCase;
     Argument            = argument;
     _miTarget           = miTarget;
     _target             = target;
     _targetConfObject   = target.Args;
     _cmdArgsParser      = cmdArgsParser;
     _target             = target;
 }
예제 #5
0
        public Bindings(bool allowUnknownArgument, CmdArgsParser <TArgs> cmdArgsParser, Res <TArgs> args,
                        List <Binding <TArgs> > __bindings)
        {
            AllowUnknownArgument = allowUnknownArgument;
            _cmdArgsParser       = cmdArgsParser;

            Args     = args;
            bindings = __bindings;
            foreach (Binding <TArgs> b in bindings)
            {
                b.bs = this;
            }
        }
예제 #6
0
 public virtual void InitAndCheck <TArgs>(MemberInfo mi, CmdArgsParser <TArgs> p, TArgs target)
     where TArgs : new()
 {
     CheckFieldType(mi.GetFieldType());
 }