Show / Hide Table of Contents

Class ServiceFactoryExtensions

Implements extensions for the IServiceFactory to call service methods asynchronously or synchronously .

Inheritance
object
ServiceFactoryExtensions
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
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 Source

CallAsync<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.

View Source

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.

View Source

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.

View Source

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.

  • View Source
Back to top Generated by DocFX