namespace InnovEnergy.Lib.Channels.V2.Connections; public abstract class Connection : IConnection where C : IDisposable { private C? _Connection; async Task IConnection .Open() => _Connection ??= await Open(); async Task IConnection.Open() => _Connection ??= await Open(); public abstract Task Open(); public void Close() { if (_Connection is null) return; _Connection!.Dispose(); _Connection = default; } public Boolean IsOpen => _Connection is not null; }