While.CommandLineOptions.IsParam C# (CSharp) Method

IsParam() private method

private IsParam ( string arg, string longForm, string shortForm, bool requireArgument, string &argument ) : bool
arg string
longForm string
shortForm string
requireArgument bool
argument string
return bool
        private bool IsParam(string arg, string longForm, string shortForm, bool requireArgument, out string argument)
        {
            Match m = Regex.Match(arg, @"^((--|/)" + longForm + "|(-|/)" + shortForm + ")", RegexOptions.IgnoreCase);
            argument = null;
            if (!m.Success) {
                return false;
            }
            if (!requireArgument && arg.Length != m.Value.Length) {
                return false;
            }
            if (requireArgument) {
                if (m.Value.Length == arg.Length) {
                    Console.Error.WriteLine("ERROR: Missing argument for option " + arg);
                    While.Environment.Exit(1);
                }
                if (arg[m.Value.Length] != ':' && arg[m.Value.Length] != '=') {
                    return false;
                }
                if (m.Value.Length+1 == arg.Length) {
                    Console.Error.WriteLine("ERROR: Missing argument for option " + arg);
                    While.Environment.Exit(1);
                }
                argument = arg.Substring(m.Value.Length + 1);
            }
            return true;
        }