Ejemplo n.º 1
0
        private void CheckForUnmappedArguments(IDictionary <string, CommandLineArgument> arguments, HashSet <CommandLineArgument> sharedArguments, T instance)
        {
            if (arguments.Count <= 0)
            {
                return;
            }

            foreach (var argument in arguments.Values.Where(arg => !sharedArguments.Contains(arg)))
            {
                UnmappedCommandLineArgument?.Invoke(this, new MapperEventArgs(argument, null, instance));
            }
        }
Ejemplo n.º 2
0
        /// <summary>Maps the give argument dictionary to the given instance.</summary>
        /// <param name="arguments">The arguments to map.</param>
        /// <param name="instance">The instance to map the arguments to.</param>
        /// <returns>The instance of the class, the command line argument were mapped to</returns>
        public T Map(IDictionary <string, CommandLineArgument> arguments, T instance)
        {
            var argumentInfo = ArgumentClassInfo.FromType <T>();
            var helpRequest  = GetHelpRequest(arguments, argumentInfo);

            if (helpRequest != null)
            {
                MapHelpOnly(instance, argumentInfo, arguments, helpRequest);
                return(instance);
            }

            if (argumentInfo.HasCommands)
            {
                MapArgumentsToCommand(instance, argumentInfo, arguments);
            }

            foreach (var argument in arguments.Values.Where(x => !x.Mapped))
            {
                UnmappedCommandLineArgument?.Invoke(this, new MapperEventArgs(argument, null, instance));
            }

            return(instance);
        }