Class DisposableServicesHandler
An utility class for handling services that should be disposed (when created by provider/builder, and not by library user).
Inheritance
Implements
Namespace: TehGM.Wolfringo.Utilities.Internal
Assembly: Wolfringo.Core.dll
Syntax
public class DisposableServicesHandler : IDisposable
Remarks
Do NOT register this service manually. It should only be initialized by builders, such as WolfClientBuilder.
Only singleton services should be marked for disposal.
Methods
| Improve this Doc View SourceDispose()
Disposes all tracked disposable services, and stops tracking them.
Declaration
public void Dispose()
Remarks
Do NOT register this service manually. It should only be initialized by builders, such as WolfClientBuilder.
Only singleton services should be marked for disposal.
GetRequiredService<T>(IServiceProvider)
Gets required service from provider. If service is marked for disposal, it'll automatically be tracked and disposed when Dispose() is used.
Declaration
public T GetRequiredService<T>(IServiceProvider services)
Parameters
| Type | Name | Description |
|---|---|---|
| System.IServiceProvider | services | Service provider to resolve the service from. |
Returns
| Type | Description |
|---|---|
| T | The resolved service. |
Type Parameters
| Name | Description |
|---|---|
| T | Type of the service to get. |
Remarks
Do NOT register this service manually. It should only be initialized by builders, such as WolfClientBuilder.
Only singleton services should be marked for disposal.
GetService<T>(IServiceProvider)
Gets service from provider. If service is marked for disposal, it'll automatically be tracked and disposed when Dispose() is used.
Declaration
public T GetService<T>(IServiceProvider services)
Parameters
| Type | Name | Description |
|---|---|---|
| System.IServiceProvider | services | Service provider to resolve the service from. |
Returns
| Type | Description |
|---|---|
| T | The resolved service; null if not found. |
Type Parameters
| Name | Description |
|---|---|
| T | Type of the service to get. |
Remarks
Do NOT register this service manually. It should only be initialized by builders, such as WolfClientBuilder.
Only singleton services should be marked for disposal.
MarkForDisposal(Type)
Marks service type to be disposed.
Declaration
public void MarkForDisposal(Type type)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | type | Type of the service. |
Remarks
Do NOT register this service manually. It should only be initialized by builders, such as WolfClientBuilder.
Only singleton services should be marked for disposal.
MarkForDisposal<T>()
Marks service type to be disposed.
Declaration
public void MarkForDisposal<T>()
Type Parameters
| Name | Description |
|---|---|
| T | Type of the service. |
Remarks
Do NOT register this service manually. It should only be initialized by builders, such as WolfClientBuilder.
Only singleton services should be marked for disposal.
UnmarkForDisposal(Type)
Removes disposal mark from the service type.
Declaration
public void UnmarkForDisposal(Type type)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | type | Type of the service. |
Remarks
Do NOT register this service manually. It should only be initialized by builders, such as WolfClientBuilder.
Only singleton services should be marked for disposal.
UnmarkForDisposal<T>()
Removes disposal mark from the service type.
Declaration
public void UnmarkForDisposal<T>()
Type Parameters
| Name | Description |
|---|---|
| T | Type of the service. |
Remarks
Do NOT register this service manually. It should only be initialized by builders, such as WolfClientBuilder.
Only singleton services should be marked for disposal.