Class ServiceFactoryExtensions
Implements extensions for the IServiceFactory to call service methods asynchronously or synchronously .
Namespace: Sartorius.SAF.Extensions
Assembly: Sartorius.SAF.dll
Syntax
public static class ServiceFactoryExtensions
Remarks
The implementation of the IServiceFactory must be obtained using the MEF import mechanism, for example using the ImportingConstructorAttribute.
Examples
The following example illustrates how to call asynchronously service function that use security token .
The following example illustrates how to call asynchronously service function.
The following example illustrates how to call asynchronously service function without result.
The following example illustrates how to call synchronously service function that use security token.
The following example illustrates how to call synchronously service function.
The following example illustrates how to call synchronously service function without result.
Methods
View SourceCallAsync<TService>(IServiceFactory, Action<TService>)
Call asynchronously a given service TService.
Declaration
public static Task CallAsync<TService>(this IServiceFactory serviceFactory, Action<TService> callOnService) where TService : class
Parameters
| Type | Name | Description |
|---|---|---|
| IServiceFactory | serviceFactory | |
| Action<TService> | callOnService | Encapsulate the service method that should be called. |
Returns
| Type | Description |
|---|---|
| Task | A instance of Task |
Type Parameters
| Name | Description |
|---|---|
| TService | A type of service. |
CallAsync<TService, TResult>(IServiceFactory, Func<TService, TResult>)
Call asynchronously a given service TService.
Declaration
public static Task<TResult> CallAsync<TService, TResult>(this IServiceFactory serviceFactory, Func<TService, TResult> callOnService) where TService : class
Parameters
| Type | Name | Description |
|---|---|---|
| IServiceFactory | serviceFactory | |
| Func<TService, TResult> | callOnService | Encapsulate the service method that should be called. |
Returns
| Type | Description |
|---|---|
| Task<TResult> | A result of service. |
Type Parameters
| Name | Description |
|---|---|
| TService | A type of service. |
| TResult | A type of result. |
Call<TService>(IServiceFactory, Action<TService>)
Call synchronously a given service TService without result.
Declaration
public static void Call<TService>(this IServiceFactory serviceFactory, Action<TService> callOnService) where TService : class
Parameters
| Type | Name | Description |
|---|---|---|
| IServiceFactory | serviceFactory | A implementation of IServiceFactory |
| Action<TService> | callOnService | Encapsulate the service method that should be called. |
Type Parameters
| Name | Description |
|---|---|
| TService | A type of service. |
Call<TService, TResult>(IServiceFactory, Func<TService, TResult>)
Call synchronously a given service TService.
Declaration
public static TResult Call<TService, TResult>(this IServiceFactory serviceFactory, Func<TService, TResult> callOnService) where TService : class
Parameters
| Type | Name | Description |
|---|---|---|
| IServiceFactory | serviceFactory | |
| Func<TService, TResult> | callOnService | Encapsulate the service method that should be called. |
Returns
| Type | Description |
|---|---|
| TResult | A result of service. |
Type Parameters
| Name | Description |
|---|---|
| TService | A type of service. |
| TResult | A type of result. |