-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ea11c31
commit b87bcd8
Showing
4 changed files
with
102 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using System.Threading.Tasks.Sources; | ||
|
||
namespace WalletConnectSharp.Core.Utils; | ||
public abstract class DisposableBase : IDisposable | ||
{ | ||
private bool _isDisposed; | ||
|
||
/// <summary> | ||
/// Default Constructor | ||
/// </summary> | ||
public DisposableBase() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// dispose managed state (managed objects). This must be implemented. | ||
/// </summary> | ||
protected abstract void DisposeManaged(); | ||
|
||
/// <summary> | ||
/// free unmanaged resources (unmanaged objects) and override finalizer | ||
/// set large fields to null | ||
/// </summary> | ||
protected virtual void DisposeUnmanaged() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Dispose Managed and Unmanaged resources | ||
/// </summary> | ||
/// <param name="disposing"></param> | ||
protected virtual void Dispose(bool disposing) | ||
{ | ||
if (!_isDisposed) | ||
{ | ||
if (disposing) | ||
{ | ||
DisposeManaged(); | ||
} | ||
DisposeUnmanaged(); | ||
_isDisposed = true; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// override finalizer only if 'Dispose(bool disposing)' | ||
/// has code to free unmanaged resources | ||
/// </summary> | ||
~DisposableBase() | ||
{ | ||
// Do not change this code. | ||
// Put cleanup code in 'Dispose(bool disposing)' method | ||
Dispose(disposing: false); | ||
} | ||
|
||
/// <summary> | ||
/// Dispose the object | ||
/// </summary> | ||
public void Dispose() | ||
{ | ||
// Do not change this code. | ||
// Put cleanup code in 'Dispose(bool disposing)' method | ||
Dispose(disposing: true); | ||
GC.SuppressFinalize(this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters