ServiceUse Method (Type, FuncObject, String, Boolean) |
Sets factoryMethod to be used as a provider of implementation of service.
Namespace: CMS.CoreAssembly: CMS.Core (in CMS.Core.dll) Version: 12.0.0
Syntax public static void Use(
Type service,
Func<Object> factoryMethod,
string name = null,
bool transient = false
)
Parameters
- service
- Type: SystemType
Type of service being implemented. - factoryMethod
- Type: SystemFuncObject
Method providing an instance of service. - 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.
Exceptions Remarks
The name does not need to be explicitly set unless registering one implementation multiple times (for various interfaces).
See Also