Registers a service using a custom factory method and certain creation and disposal policies.

Namespace: DigitalRune.ServiceLocation
Assembly: DigitalRune.ServiceLocation (in DigitalRune.ServiceLocation.dll) Version: 1.0.0.0 (1.0.0.9503)

Syntax

C#
public void Register(
	Type serviceType,
	string key,
	Func<ServiceContainer, Object> createInstance,
	CreationPolicy creationPolicy,
	DisposalPolicy disposalPolicy
)
Visual Basic
Public Sub Register ( _
	serviceType As Type, _
	key As String, _
	createInstance As Func(Of ServiceContainer, Object), _
	creationPolicy As CreationPolicy, _
	disposalPolicy As DisposalPolicy _
)
Visual C++
public:
void Register(
	Type^ serviceType, 
	String^ key, 
	Func<ServiceContainer^, Object^>^ createInstance, 
	CreationPolicy creationPolicy, 
	DisposalPolicy disposalPolicy
)

Parameters

serviceType
Type: System..::..Type
The type of the service.
key
Type: System..::..String
The name under which the object should be registered. Can be nullNothingnullptra null reference (Nothing in Visual Basic) or empty.
createInstance
Type: System..::..Func<(Of <(<'ServiceContainer, Object>)>)>
The factory method responsible for serving the requests from the container.
creationPolicy
Type: DigitalRune.ServiceLocation..::..CreationPolicy
The creation policy that specifies when and how a service will be instantiated.
disposalPolicy
Type: DigitalRune.ServiceLocation..::..DisposalPolicy
The disposal policy that specifies when a service instance will be disposed. (Only relevant if the service instance implements IDisposable.)

Remarks

If a service with the same type and name is already registered, the existing entry will be replaced.

Exceptions

ExceptionCondition
System..::..ArgumentNullExceptionserviceType or createInstance is nullNothingnullptra null reference (Nothing in Visual Basic).

See Also