Пример #1
0
 /*
  * Connects to server somehow, prioritising connection settings from input, defaulting
  * to configuration settings if no connection settings are specified by caller.
  */
 public static async Task Connect(Node input, IMailClient client, ConnectionSettings server)
 {
     // Connecting and to server.
     await client.ConnectAsync(
         input.Children
         .FirstOrDefault(x => x.Name == "server")?
         .Children
         .FirstOrDefault(x => x.Name == "host")?
         .GetEx <string>() ?? server.Host,
         input.Children
         .FirstOrDefault(x => x.Name == "server")?
         .Children.FirstOrDefault(x => x.Name == "port")?
         .GetEx <int>() ?? server.Port,
         input.Children
         .FirstOrDefault(x => x.Name == "server")?
         .Children.FirstOrDefault(x => x.Name == "secure")?
         .GetEx <bool>() ?? server.Secure);
 }