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