Example #1
0
 public AsterManager(IOptions <AsterManagerConfig> options)
 {
     AsterManagerConfig.Validate(options.Value);
     _managerConnection = new ManagerConnection(
         options.Value.Hostname,
         options.Value.Port,
         options.Value.Username,
         options.Value.Password
         );
     _managerConnection.DefaultEventTimeout    = 10000;
     _managerConnection.DefaultResponseTimeout = 10000;
 }
Example #2
0
 public static void Validate(AsterManagerConfig config)
 {
     if (!Utils.IsDomain(config.Hostname) && !Utils.IsIPAddress(config.Hostname))
     {
         throw new FormatException($"Failed to convert {config.Hostname} to hostname or IP address");
     }
     if (!Utils.IsPort(config.Port))
     {
         throw new FormatException($"Failed to convert {config.Port} to port");
     }
     if (string.IsNullOrEmpty(config.Username))
     {
         throw new FormatException($"Failed to convert null or empty value to username");
     }
     if (string.IsNullOrEmpty(config.Password))
     {
         throw new FormatException($"Failed to convert null or empty value to password");
     }
 }