Show / Hide Table of Contents

Class ServiceFactory

Implements functionality to get services or instances from the composition container or as WCF proxy.

Inheritance
object
ServiceFactory
Implements
IServiceFactory
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Sartorius.SAF.ServiceLocation
Assembly: Sartorius.SAF.dll
Syntax
public class ServiceFactory : IServiceFactory

Constructors

View Source

ServiceFactory(CompositionContainer)

Initializes a new instance of the ServiceFactory.

Declaration
public ServiceFactory(CompositionContainer compositionContainer)
Parameters
Type Name Description
CompositionContainer compositionContainer

The instance of the CompositionContainer that holds all exported types.

Properties

View Source

Container

Gets the current CompositionContainer.

Declaration
public static CompositionContainer Container { get; }
Property Value
Type Description
CompositionContainer

Methods

View Source

CloseService(object)

Closes the given instance of the service.

Declaration
public void CloseService(object service)
Parameters
Type Name Description
object service
View Source

GetInstanceOrDefault<T>(string)

Gets an instance of the given type.

Declaration
public T GetInstanceOrDefault<T>(string name = null) where T : class
Parameters
Type Name Description
string name

The contract name.

Returns
Type Description
T

The service instance or null if not found.

Type Parameters
Name Description
T

A type of the service.

View Source

GetInstance<T>(string)

Gets an instance of the given type.

Declaration
public T GetInstance<T>(string name = null) where T : class
Parameters
Type Name Description
string name

The name.

Returns
Type Description
T

The service instance.

Type Parameters
Name Description
T
Exceptions
Type Condition
ActivationException

If instance not found.

Implements

IServiceFactory

Extension Methods

ServiceFactoryExtensions.CallAsync<TService>(IServiceFactory, Action<TService>)
ServiceFactoryExtensions.CallAsync<TService, TResult>(IServiceFactory, Func<TService, TResult>)
ServiceFactoryExtensions.Call<TService>(IServiceFactory, Action<TService>)
ServiceFactoryExtensions.Call<TService, TResult>(IServiceFactory, Func<TService, TResult>)
CollectionExtensions.AddRange<T, TCollection>(TCollection, IEnumerable<T>)
SerializableObjectCloneExtension.Clone<T>(T)
  • View Source
Back to top Generated by DocFX