/// <summary> /// Initializes a new instance of the <see cref="ImapClient"/> class. /// </summary> /// <param name="tls">The TLS encryptor.</param> /// <param name="simultConnections">The simultaneous connections count.</param> /// <exception cref="ArgumentNullException"> /// Throws when tls is null /// </exception> /// <exception cref="ArgumentOutOfRangeException"> /// Throws when connections limit exceeded /// </exception> public ImapClient(ITlsEncryptor tls, int simultConnections = 5) { _tls = tls ?? throw new ArgumentNullException(nameof(ImapClient) + " Null argument"); _simultConnections = simultConnections <= MAX_SIMULT ? simultConnections : throw new ArgumentOutOfRangeException(); _hSemaphore = new Semaphore(simultConnections, simultConnections); _freeStreams = new Queue <int>(); // fill free streams for (int i = 0; i < simultConnections; _freeStreams.Enqueue(i++)) { } }
/// <summary> /// Initializes a new instance of the <see cref="SmtpConnection"/> class. /// </summary> /// <param name="tls">The TLS.</param> /// <exception cref="ArgumentNullException">SmtpConnection</exception> public SmtpConnection(ITlsEncryptor tls) { _tls = tls ?? throw new ArgumentNullException(nameof(SmtpConnection) + " Null argument"); _commandsAvailable = new List <string>(); }