public override void Execute()
        {
            base.Execute();

            List <string>      singleOptionList = KillProcessOptions.GetSingleOptions();
            CommandLineOptions cloptions        = CommandLineParser.Parse(Arguments.ToArray <string>(), singleOptionList.ToArray());

            options = ParseOptions(cloptions);
            CheckOptions(options);

            if (options.IsSetHelp)
            {
                RaiseCommandLineUsage(this, KillProcessOptions.Usage);
            }
            else if (options.IsSetVersion)
            {
                RaiseCommandLineUsage(this, Version);
            }
            else
            {
                StartKillProcess();
            }

            Terminate();
        }
        private static KillProcessCommandLineOptions ParseOptions(CommandLineOptions commandLineOptions)
        {
            if (commandLineOptions == null)
            {
                throw new CommandLineException(string.Format(CultureInfo.CurrentCulture,
                                                             "Option used in invalid context -- {0}", "must specify a option."));
            }

            KillProcessCommandLineOptions targetOptions = new KillProcessCommandLineOptions();

            if (commandLineOptions.Arguments.Count >= 0)
            {
                foreach (var arg in commandLineOptions.Arguments.Keys)
                {
                    KillProcessOptionType optionType = KillProcessOptions.GetOptionType(arg);
                    if (optionType == KillProcessOptionType.None)
                    {
                        throw new CommandLineException(
                                  string.Format(CultureInfo.CurrentCulture, "Option used in invalid context -- {0}",
                                                string.Format(CultureInfo.CurrentCulture, "cannot parse the command line argument : [{0}].", arg)));
                    }

                    switch (optionType)
                    {
                    case KillProcessOptionType.Pid:
                        targetOptions.IsSetPid = true;
                        targetOptions.Pid      = commandLineOptions.Arguments[arg];
                        break;

                    case KillProcessOptionType.Name:
                        targetOptions.IsSetName = true;
                        targetOptions.Name      = commandLineOptions.Arguments[arg];
                        break;

                    case KillProcessOptionType.Help:
                        targetOptions.IsSetHelp = true;
                        break;

                    case KillProcessOptionType.Version:
                        targetOptions.IsSetVersion = true;
                        break;
                    }
                }
            }

            if (commandLineOptions.Parameters.Count > 0)
            {
                if (string.IsNullOrEmpty(targetOptions.Pid))
                {
                    targetOptions.IsSetPid = true;
                    targetOptions.Pid      = commandLineOptions.Parameters.First();
                }
            }

            return(targetOptions);
        }