TryDisposable 1.5.1
See the version list below for details.
dotnet add package TryDisposable --version 1.5.1
NuGet\Install-Package TryDisposable -Version 1.5.1
<PackageReference Include="TryDisposable" Version="1.5.1" />
paket add TryDisposable --version 1.5.1
#r "nuget: TryDisposable, 1.5.1"
// Install TryDisposable as a Cake Addin #addin nuget:?package=TryDisposable&version=1.5.1 // Install TryDisposable as a Cake Tool #tool nuget:?package=TryDisposable&version=1.5.1
TryDisposable
Wrap an object in a disposable decorator to attempt to dispose the object later. This is useful when retrieving an instance of an object from a factory or container while only having an interface reference. If the interface does not implement IDisposable, but the concrete class does, this will allow the instance to be disposed.
##Example 1
Use the simple TryDispose() method available on any object.
object obj = new object();
obj.TryDispose();
##Example 2
Wrap an object in a using statement. Use the instance property to access the object.
ITemporaryFolder tempFolder = TemporaryFolder.Factory.Create();
using (ITryDisposable<ITemporaryFolder> disposableTempFolder = TryDisposableFactory.Create(tempFolder))
{
string path = disposableTempFolder.Instance.Path;
// If tempFolder is disposable, it will get disposed, otherwise it will be ignored.
}
##Example 2
Use the following if the underlying object does not need to be accessed through the ITryDisposbale<TUnderlyingItem> interface.
using (ITryDisposable disposableTempFolder = TryDisposableFactory.Create(tempFolder))
{
// If tempFolder is disposable, it will get disposed, otherwise it will be ignored.
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp1.0 was computed. netcoreapp1.1 was computed. netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 is compatible. |
.NET Standard | netstandard1.3 is compatible. netstandard1.4 was computed. netstandard1.5 was computed. netstandard1.6 was computed. netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen30 was computed. tizen40 was computed. tizen60 was computed. |
Universal Windows Platform | uap was computed. uap10.0 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETCoreApp 3.1
- No dependencies.
-
.NETFramework 4.5
- No dependencies.
-
.NETFramework 4.6.1
- No dependencies.
-
.NETStandard 1.3
- NETStandard.Library (>= 1.6.1)
-
.NETStandard 2.0
- No dependencies.
-
.NETStandard 2.1
- No dependencies.
-
net5.0
- No dependencies.
-
net6.0
- No dependencies.
NuGet packages (12)
Showing the top 5 NuGet packages that depend on TryDisposable:
Package | Downloads |
---|---|
Diamond.Core.Workflow.State
This library provides an implementation of the state dictionary and provides several default type converters. |
|
Diamond.Core.Workflow
This library provides workflow interfaces and abstract or default implementations for common patterns. |
|
Diamond.Core.AspNetCore.DoAction
Provides the Do pattern execution for ASP.NET Core MVC core projects. |
|
Diamond.Patterns.WorkFlow
This library provides work-flow interfaces and abstract or default implementations for common patterns. |
|
Diamond.Core.Decorator
This library provides a basic implementation of the decorator factory. |
GitHub repositories
This package is not used by any popular GitHub repositories.