public CommandLineArgumentParser()

in src/FabActUtil/CommandLineParser/CommandLineArgumentParser.cs [54:107]


        public CommandLineArgumentParser(Type argumentSpecification, ErrorReporter reporter)
        {
            this.reporter = reporter;
            this.arguments = new ArrayList();
            this.argumentMap = new Hashtable();

            foreach (var field in argumentSpecification.GetFields())
            {
                if (!field.IsStatic && !field.IsInitOnly && !field.IsLiteral)
                {
                    var attribute = GetAttribute(field);
                    if (attribute is DefaultCommandLineArgumentAttribute)
                    {
                        Debug.Assert(this.defaultArgument == null, "The default argument must not be null.");
                        this.defaultArgument = new Argument(attribute, field, reporter);
                    }
                    else
                    {
                        this.arguments.Add(new Argument(attribute, field, reporter));
                    }
                }
            }

            // add explicit names to map
            foreach (Argument argument in this.arguments)
            {
                Debug.Assert(
                    !this.argumentMap.ContainsKey(argument.LongName),
                    "The argument must exist in the argument map.");

                this.argumentMap[argument.LongName] = argument;

                if (argument.ExplicitShortName && !string.IsNullOrEmpty(argument.ShortName))
                {
                    Debug.Assert(
                        !this.argumentMap.ContainsKey(argument.ShortName),
                        "The argument must exists for the short name");

                    this.argumentMap[argument.ShortName] = argument;
                }
            }

            // add implicit names which don't collide to map
            foreach (Argument argument in this.arguments)
            {
                if (!argument.ExplicitShortName && !string.IsNullOrEmpty(argument.ShortName))
                {
                    if (!this.argumentMap.ContainsKey(argument.ShortName))
                    {
                        this.argumentMap[argument.ShortName] = argument;
                    }
                }
            }
        }