Click or drag to resize
ServiceUseTService Method (FuncObject, String, Boolean, RegistrationPriority)
Sets factoryMethod to be used as a provider of implementation of TService.

Namespace: CMS.Core
Assembly: CMS.Core (in CMS.Core.dll) Version: 13.0.131
Syntax
C#
public static void Use<TService>(
	Func<Object> factoryMethod,
	string name = null,
	bool transient = false,
	RegistrationPriority registrationPriority = RegistrationPriority.Default
)

Parameters

factoryMethod
Type: SystemFuncObject
Method providing an instance of TService.
name (Optional)
Type: SystemString
Sets an explicit name of the registration. If not set, the name is automatically inferred from the implementation being registered. Name must be unique.
transient (Optional)
Type: SystemBoolean
Indicates whether service implementation lifestyle should be transient, or default to singleton.
registrationPriority (Optional)
Type: CMS.CoreRegistrationPriority
Defines the registration priority.

Type Parameters

TService
Service being implemented.
Exceptions
ExceptionCondition
ArgumentNullExceptionThrown when factoryMethod is null.
ServiceRegistrationExceptionThrown when registration fails (e.g. name is not unique).
Remarks
The name does not need to be explicitly set unless registering one implementation multiple times (for various interfaces).
See Also