IMutableDependencyResolver.RegisterConstant(T?) method¶
Defined in
Type: IMutableDependencyResolver
Namespace: Splat
Assembly: Splat.Core.dll
Applies to
net10.0, net10.0-browserwasm1.0, net10.0-desktop1.0, net9.0, net9.0-browserwasm1.0, net9.0-desktop1.0, net8.0, net8.0-ios17.5, net8.0-maccatalyst17.5, net8.0-macos14.2, net8.0-macos14.5, net8.0-tvos17.2, netstandard2.1, net462, net481
Overloads¶
- 1.
void RegisterConstant<T>(T? value) where T : class - 2.
void RegisterConstant<T>(T? value, string? contract) where T : class
1. Overload¶
void RegisterConstant<T>(T? value) where T : class
Summary: Registers a constant value of the specified reference type for later retrieval or use.
Type parameters
| Name | Description |
|---|---|
T | The reference type of the constant value to register. |
Parameters
| Name | Type | Description |
|---|---|---|
value | T? | The constant value to register. Can be null to represent the absence of a value. |
2. Overload¶
void RegisterConstant<T>(T? value, string? contract) where T : class
Summary: Registers a constant instance of the specified type for use in dependency resolution.
Type parameters
| Name | Description |
|---|---|
T | The type of the constant instance to register. Must be a reference type. |
Parameters
| Name | Type | Description |
|---|---|---|
value | T? | The constant instance to register. Can be null if null values are supported by the container. |
contract | string? | An optional contract name that uniquely identifies the registration. Can be null to register without a contract. |
Remarks
Registering a constant ensures that the same instance is returned for all requests matching the specified type and contract. If a contract is provided, the constant is associated only with that contract; otherwise, it is registered for the type without a contract.