System.DisposableObject
8.0.0
dotnet add package System.DisposableObject --version 8.0.0
NuGet\Install-Package System.DisposableObject -Version 8.0.0
<PackageReference Include="System.DisposableObject" Version="8.0.0" />
paket add System.DisposableObject --version 8.0.0
#r "nuget: System.DisposableObject, 8.0.0"
// Install System.DisposableObject as a Cake Addin #addin nuget:?package=System.DisposableObject&version=8.0.0 // Install System.DisposableObject as a Cake Tool #tool nuget:?package=System.DisposableObject&version=8.0.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 Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. |
-
net8.0
- No dependencies.
NuGet packages (12)
Showing the top 5 NuGet packages that depend on System.DisposableObject:
Package | Downloads |
---|---|
Diamond.Patterns.Context
This library provides context implementations the work-flows and other context based operations. |
|
Diamond.Core.System.TemporaryFolder
This library provides code performance tools. |
|
Diamond.Patterns.System
This library provides some basic support functionality. |
|
System.Data.FileDatabase
A library for easy access to File based databases such as Microsoft Access, flat files or Excel Spreadsheets. |
|
Diamond.Core.Repository.EntityFrameworkCore
This library provides an implementation of the repository that can be used with Entity Framework Core. |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on System.DisposableObject:
Repository | Stars |
---|---|
porrey/Virtual-ZPL-Printer
An ethernet based virtual Zebra Label Printer that can be used to test applications that produce bar code labels.
|