mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-25 19:38:37 +08:00
28 lines
550 B
C#
28 lines
550 B
C#
using System;
|
|
using System.Linq;
|
|
|
|
namespace mRemoteNG.Tools
|
|
{
|
|
public class DisposableOptional<T> : Optional<T>, IDisposable
|
|
where T : IDisposable
|
|
{
|
|
public DisposableOptional(T value)
|
|
: base(value)
|
|
{
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
Dispose(true);
|
|
GC.SuppressFinalize(this);
|
|
}
|
|
|
|
private void Dispose(bool disposing)
|
|
{
|
|
if (!disposing || !this.Any())
|
|
return;
|
|
|
|
this.First().Dispose();
|
|
}
|
|
}
|
|
} |