Class ServiceFactory
Implements functionality to get services or instances from the composition container or as WCF proxy.
Inheritance
System.Object
ServiceFactory
Implements
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Sartorius.SAF.ServiceLocation
Assembly: Sartorius.SAF.dll
Syntax
public class ServiceFactory : IServiceFactory
Constructors
View SourceServiceFactory(CompositionContainer)
Initializes a new instance of the ServiceFactory.
Declaration
public ServiceFactory(CompositionContainer compositionContainer)
Parameters
| Type | Name | Description |
|---|---|---|
| System.ComponentModel.Composition.Hosting.CompositionContainer | compositionContainer | The instance of the CompositionContainer that holds all exported types. |
Properties
View SourceContainer
Gets the current CompositionContainer.
Declaration
public static CompositionContainer Container { get; }
Property Value
| Type | Description |
|---|---|
| System.ComponentModel.Composition.Hosting.CompositionContainer |
Methods
View SourceCloseService(Object)
Closes the given instance of the service.
Declaration
public void CloseService(object service)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | service |
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 |
|---|---|---|
| System.String | name | The name. |
Returns
| Type | Description |
|---|---|
| T | The service instance. |
Type Parameters
| Name | Description |
|---|---|
| T |
Exceptions
| Type | Condition |
|---|---|
| CommonServiceLocator.ActivationException | If instance not found. |
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 |
|---|---|---|
| System.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. |