internal static void Invoke(object instance, string arguments, MethodInfo methodInfo, IEnumerable<SwitchDescriptor> switches)
        {
            var helper = new SwitchHelper(switches);
            helper.Parse(instance, arguments);

            var values = new ArrayList();
            var descriptors = switches.ToDictionary(item => item.DescriptorName);

            foreach (var item in methodInfo.GetParameters())
            {
                var descriptor = descriptors[item.Name];

                var value = descriptor.GetValue(instance);
                values.Add(value);
            }

            methodInfo.Invoke(instance, values.ToArray());
        }
        public bool Parse(string commandLine)
        {
            var match = Regex.Match(commandLine, @"^((""[^""]*"")|(\S+))");
            var name = match.Value.Trim(new char[] { '\"', });

            if (File.Exists(name) == true)
                name = Process.GetCurrentProcess().ProcessName;

            if (this.name != name)
                throw new ArgumentException(string.Format(Resources.InvalidCommandName_Format, name));

            var arguments = commandLine.Substring(match.Length).Trim();

            if (arguments == this.HelpName)
            {
                this.PrintUsage();
                return false;
            }
            else if (arguments == this.VersionName)
            {
                this.PrintVersion();
                return false;
            }
            else
            {
                var descriptors = CommandDescriptor.GetSwitchDescriptors(this.instance).Where(item => this.IsSwitchVisible(item));
                var helper = new SwitchHelper(descriptors);
                helper.Parse(this.instance, arguments);
                return true;
            }
        }