-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added EnsureExtensions for IDisposable objects.
Disposing logic reorganized. Now all exceptions correctly ignored. Closes #1, closes #5 and closes #6. Version 0.0.2.
- Loading branch information
Showing
8 changed files
with
108 additions
and
45 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
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,44 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.Runtime.CompilerServices; | ||
using Platform.Exceptions; | ||
|
||
#pragma warning disable IDE0060 // Remove unused parameter | ||
|
||
namespace Platform.Disposables | ||
{ | ||
public static class EnsureExtensions | ||
{ | ||
#region Always | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public static void NotDisposed(this EnsureAlwaysExtensionRoot root, IDisposable disposable) => NotDisposed(root, disposable, null, null); | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public static void NotDisposed(this EnsureAlwaysExtensionRoot root, IDisposable disposable, string objectName) => NotDisposed(root, disposable, objectName, null); | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public static void NotDisposed(this EnsureAlwaysExtensionRoot root, IDisposable disposable, string objectName, string message) | ||
{ | ||
if (disposable.IsDisposed) | ||
{ | ||
throw new ObjectDisposedException(objectName, message); | ||
} | ||
} | ||
|
||
#endregion | ||
|
||
#region OnDebug | ||
|
||
[Conditional("DEBUG")] | ||
public static void NotDisposed(this EnsureOnDebugExtensionRoot root, IDisposable disposable) => Ensure.Always.NotDisposed(disposable, null, null); | ||
|
||
[Conditional("DEBUG")] | ||
public static void NotDisposed(this EnsureOnDebugExtensionRoot root, IDisposable disposable, string objectName) => Ensure.Always.NotDisposed(disposable, objectName, null); | ||
|
||
[Conditional("DEBUG")] | ||
public static void NotDisposed(this EnsureOnDebugExtensionRoot root, IDisposable disposable, string objectName, string message) => Ensure.Always.NotDisposed(disposable, objectName, message); | ||
|
||
#endregion | ||
} | ||
} |
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
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