public static void Validate(ServiceControlConf config) { if (string.IsNullOrEmpty(config.Token)) { throw new FormatException($"Failed to convert null or empty value to token"); } if (!Utils.IsIPAddress(config.ListenAddress)) { throw new FormatException($"Failed to convert {config.ListenAddress} to IP address"); } if (!Utils.IsPort(config.Port)) { throw new FormatException($"Failed to convert {config.Port} to port"); } }
public ServiceControl(IOptions <ServiceControlConf> options) { ServiceControlConf.Validate(options.Value); _options = options; }