System.DisposableObject
1.5.0
See the version list below for details.
Install-Package System.DisposableObject -Version 1.5.0
dotnet add package System.DisposableObject --version 1.5.0
<PackageReference Include="System.DisposableObject" Version="1.5.0" />
paket add System.DisposableObject --version 1.5.0
#r "nuget: System.DisposableObject, 1.5.0"
// Install System.DisposableObject as a Cake Addin
#addin nuget:?package=System.DisposableObject&version=1.5.0
// Install System.DisposableObject as a Cake Tool
#tool nuget:?package=System.DisposableObject&version=1.5.0
System.DisposableObject
Base object for disposing managed and unmanaged objects. This object implements the dispose pattern for the .NET Framework.
Example
Create a class and inherit from DisposableObject as shown below:
using System;
public class SomeObject : DisposableObject
{
protected override void OnDisposeManagedObjects()
{
// ***
// *** Disposed CLR managed objects here.
// ***
}
protected override void OnDisposeUnmanagedObjects()
{
// ***
// *** Disposed non-CLR managed objects here.
// ***
}
}
Override one or both of the above methods depending on the type of resources your class uses.
When instantiating the class. wrap it in a using statement.
using (SomeObject obj = new SomeObject())
{
// ***
// *** obj will be disposed and the dispose
// *** methods will be called.
}
or call the Dispose() method.
SomeObject obj = new SomeObject();
obj.Dispose();
In either case, the OnDisposeManagedObjects() and OnDisposeUnmanagedObjects() are called.
References
Product | Versions |
---|---|
.NET | net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows |
.NET Core | netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1 |
.NET Standard | netstandard2.0 netstandard2.1 |
.NET Framework | net40 net403 net45 net451 net452 net46 net461 net462 net463 net47 net471 net472 net48 |
MonoAndroid | monoandroid |
MonoMac | monomac |
MonoTouch | monotouch |
Tizen | tizen40 tizen60 |
Xamarin.iOS | xamarinios |
Xamarin.Mac | xamarinmac |
Xamarin.TVOS | xamarintvos |
Xamarin.WatchOS | xamarinwatchos |
-
.NETCoreApp 3.1
- No dependencies.
-
.NETFramework 4.0
- No dependencies.
-
.NETFramework 4.5
- No dependencies.
-
.NETFramework 4.6.1
- No dependencies.
-
.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 System.DisposableObject:
Package | Downloads |
---|---|
System.Data.FileDatabase
A library for easy access to File based databases such as Microsoft Access, flat files or Excel Spreadsheets. |
|
Diamond.Patterns.Context
This library provides context implementations the work-flows and other context based operations. |
|
Diamond.Patterns.System
This library provides some basic support functionality. |
|
Diamond.Patterns.Repository.EntityFramework
This library provides an implementation of the repository that can be used with Entity Framework. |
|
Diamond.Patterns.UnityConfiguration
This library provides extension methods to load Unity configuration from files other than the application configuration file. |
GitHub repositories
This package is not used by any popular GitHub repositories.