public override DataTable GetSchema(string collection) { return(ConnectionPrimary?.State == ConnectionState.Open ? ConnectionPrimary.GetSchema(collection) : ConnectionSecondary?.State == ConnectionState.Open ? ConnectionSecondary.GetSchema(collection) : null); }
public override void Open() { if (ConnectionPrimary != null) { TimeSpan timeout = TimeSpan.FromSeconds(60); _idleTimeTimerPrimary = new Timer(_idleTimeTimerCallback, ConnectionPrimary, timeout, timeout); try { ConnectionPrimary.Open(); } catch { StateRedundant = _stateRedundant | ConnectionStateRedundant.BrokenPrimary; _tryOpenSecondary(); if (ConnectionSecondary == null || ConnectionSecondary.State != ConnectionState.Open) { throw; } } } _tryOpenSecondary(); }
public override void Close() { if (ConnectionPrimary != null) { lock (ConnectionPrimary) { _idleTimeTimerPrimary.Dispose(); _idleTimeTimerPrimary = null; ConnectionPrimary.Close(); ConnectionPrimary.StateChange -= _connection_StateChange; } } if (ConnectionSecondary != null) { lock (ConnectionSecondary) { _idleTimeTimerSecondary.Dispose(); _idleTimeTimerSecondary = null; ConnectionSecondary.Close(); ConnectionSecondary.StateChange -= _connection_StateChange; } } }