static HttpPortRange ParsePortRangeOption(ArgumentResult result)
            {
                var source = result.Tokens[0].Value;

                if (string.IsNullOrWhiteSpace(source))
                {
                    result.ErrorMessage = "Must specify a port range";
                    return(null);
                }

                var parts = source.Split(new[] { "-" }, StringSplitOptions.RemoveEmptyEntries);

                if (parts.Length != 2)
                {
                    result.ErrorMessage = "Must specify a port range";
                    return(null);
                }

                if (!int.TryParse(parts[0], out var start) || !int.TryParse(parts[1], out var end))
                {
                    result.ErrorMessage = "Must specify a port range as StartPort-EndPort";
                    return(null);
                }

                if (start > end)
                {
                    result.ErrorMessage = "Start port must be lower then end port";
                    return(null);
                }

                var pr = new HttpPortRange(start, end);

                return(pr);
            }
Beispiel #2
0
 public StartupOptions(
     DirectoryInfo logPath       = null,
     bool verbose                = false,
     HttpPortRange httpPortRange = null,
     HttpPort httpPort           = null)
 {
     LogPath       = logPath;
     Verbose       = verbose;
     HttpPortRange = httpPortRange;
     HttpPort      = httpPort;
 }