public LinkChannel(LinkConfiguration configuration, ILinkConnection connection) { if (configuration == null) throw new ArgumentNullException(nameof(configuration)); if (connection == null) throw new ArgumentNullException(nameof(connection)); _configuration = configuration; _logger = _configuration.LoggerFactory.CreateLogger($"{GetType().Name}({Id:D})"); if (_logger == null) throw new ArgumentException("Cannot create logger", nameof(configuration.LoggerFactory)); _disposedCancellationSource = new CancellationTokenSource(); _disposedCancellation = _disposedCancellationSource.Token; Connection = connection; Connection.Disposed += ConnectionOnDisposed; Connection.Connected += ConnectionOnConnected; _logger.Debug($"Created(connectionId: {Connection.Id:D})"); ScheduleReopen(false); }
public LinkChannel(ILinkConnection connection, LinkStateHandler <LinkChannelState> stateHandler, TimeSpan recoveryInterval) : base(LinkChannelState.Init) { _connection = connection ?? throw new ArgumentNullException(nameof(connection)); _logger = connection.Configuration.LoggerFactory.CreateLogger($"{GetType().Name}({Id:D})") ?? throw new ArgumentException("Cannot create logger", nameof(connection.Configuration.LoggerFactory)); if (recoveryInterval <= TimeSpan.Zero) { throw new ArgumentOutOfRangeException(nameof(recoveryInterval), "Must be greater than zero"); } _stateHandler = stateHandler ?? throw new ArgumentNullException(nameof(stateHandler)); _recoveryInterval = recoveryInterval; _disposeCts = new CancellationTokenSource(); _disposeCancellation = _disposeCts.Token; _connection.Disposed += ConnectionOnDisposed; _logger.Debug($"Created(connectionId: {_connection.Id:D})"); }
public Link(string connectionString, Action<ILinkConfigurationBuilder> config = null) { if (string.IsNullOrWhiteSpace(connectionString)) throw new ArgumentNullException(nameof(connectionString)); var configBuilder = new LinkConfigurationBuilder(); config?.Invoke(configBuilder); _configuration = configBuilder.Configuration; _configuration.ConnectionString = connectionString; _connection = new LinkConnection(_configuration); }
/// <summary> /// Creates new <see cref="Link" /> instance /// </summary> public Link(LinkConfiguration configuration) { _configuration = configuration; _connection = new LinkConnection(_configuration); }