Class ServiceHelper
A service helper.
Inheritance
Inherited Members
Namespace: Kephas.Services
Assembly: Kephas.Core.dll
Syntax
public static class ServiceHelper
Methods
| Improve this Doc View SourceFinalize(Object, IContext)
Finalizes the service.
Declaration
public static void Finalize(object service, IContext context = null)
Parameters
Type | Name | Description |
---|---|---|
System.Object | service | The service. |
IContext | context | Optional. The context. |
Remarks
If the service implements IAsyncFinalizable, the FinalizeAsync(IContext, CancellationToken) method is called synchronously. If the service implements IFinalizable, the Finalize(IContext) method is called. If the service implements System.IDisposable, the System.IDisposable.Dispose() method is called. Otherwise nothing happens.
FinalizeAsync(Object, IContext, CancellationToken)
Finalizes the service asynchronously.
Declaration
public static Task FinalizeAsync(object service, IContext context = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Object | service | The service. |
IContext | context | Optional. The context. |
System.Threading.CancellationToken | cancellationToken | Optional. A token that allows processing to be cancelled. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | An asynchronous result. |
Remarks
If the service implements IAsyncFinalizable, the FinalizeAsync(IContext, CancellationToken) method is called and its result is returned. If the service implements IFinalizable, the Finalize(IContext) method is called and a completed task is returned. If the service implements System.IDisposable, the System.IDisposable.Dispose() method is called and a completed task is returned. Otherwise nothing happens.
Initialize(Object, IContext)
Initializes the service.
Declaration
public static void Initialize(object service, IContext context = null)
Parameters
Type | Name | Description |
---|---|---|
System.Object | service | The service. |
IContext | context | Optional. The context. |
Remarks
If the service implements IAsyncInitializable, the InitializeAsync(IContext, CancellationToken) method is synchronously called. If the service implements IInitializable, the Initialize(IContext) method is called. Otherwise nothing happens.
InitializeAsync(Object, IContext, CancellationToken)
Initializes the service asynchronously.
Declaration
public static Task InitializeAsync(object service, IContext context = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Object | service | The service. |
IContext | context | Optional. The context. |
System.Threading.CancellationToken | cancellationToken | Optional. A token that allows processing to be cancelled. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | An asynchronous result. |
Remarks
If the service implements IAsyncInitializable, the InitializeAsync(IContext, CancellationToken) method is called and its result is returned. If the service implements IInitializable, the Initialize(IContext) method is called and a completed task is returned. Otherwise nothing happens.