Class DisposableServicesHandler
An utility class for handling services that should be disposed (when created by provider/builder, and not by library user).
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()
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 |
---|---|---|
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. |
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 |
---|---|---|
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. |
MarkForDisposal(Type)
Marks service type to be disposed.
Declaration
public void MarkForDisposal(Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type | Type of the service. |
MarkForDisposal<T>()
Marks service type to be disposed.
Declaration
public void MarkForDisposal<T>()
Type Parameters
Name | Description |
---|---|
T | Type of the service. |
UnmarkForDisposal(Type)
Removes disposal mark from the service type.
Declaration
public void UnmarkForDisposal(Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type | Type of the service. |
UnmarkForDisposal<T>()
Removes disposal mark from the service type.
Declaration
public void UnmarkForDisposal<T>()
Type Parameters
Name | Description |
---|---|
T | Type of the service. |