ParseCommandLine() публичный Метод

Parse the command-line arguments
public ParseCommandLine ( string args ) : bool
args string Command-line arguments
Результат bool
Пример #1
0
        private static ProgramOptions ParseCommandLine(string[] args)
        {
            ProgramOptions options = new ProgramOptions();
            if(!options.ParseCommandLine(args))
                return null;

            if(string.IsNullOrWhiteSpace(options.AuthorityName) && options.Usage != CertificatesAuthority.Usage.Authority)
            {
                Console.WriteLine("Invalid name of the certificate authority");
                Console.WriteLine();
                options.ShowUsage();
                return null;
            }

            if(string.IsNullOrWhiteSpace(options.CertificateName) && string.IsNullOrWhiteSpace(options.Pkcs10File))
            {
                Console.WriteLine("Please provide a name for the certificate or the name of a PKCS#10 file");
                Console.WriteLine();
                options.ShowUsage();
                return null;
            }

            if(!string.IsNullOrWhiteSpace(options.CertificateName) && !string.IsNullOrWhiteSpace(options.Pkcs10File))
            {
                Console.WriteLine("Please provide either a name for the certificate or the name of a PKCS#10 file but not both");
                Console.WriteLine();
                options.ShowUsage();
                return null;
            }

            return options;
        }
Пример #2
0
        private static ProgramOptions ParseCommandLine(string[] args)
        {
            ProgramOptions options = new ProgramOptions();

            if (!options.ParseCommandLine(args))
            {
                return(null);
            }

            if (string.IsNullOrWhiteSpace(options.AuthorityName) && options.Usage != CertificatesAuthority.Usage.Authority)
            {
                Console.WriteLine("Invalid name of the certificate authority");
                Console.WriteLine();
                options.ShowUsage();
                return(null);
            }

            if (string.IsNullOrWhiteSpace(options.CertificateName) && string.IsNullOrWhiteSpace(options.Pkcs10File))
            {
                Console.WriteLine("Please provide a name for the certificate or the name of a PKCS#10 file");
                Console.WriteLine();
                options.ShowUsage();
                return(null);
            }

            if (!string.IsNullOrWhiteSpace(options.CertificateName) && !string.IsNullOrWhiteSpace(options.Pkcs10File))
            {
                Console.WriteLine("Please provide either a name for the certificate or the name of a PKCS#10 file but not both");
                Console.WriteLine();
                options.ShowUsage();
                return(null);
            }

            return(options);
        }