Class MessageProviderRegistry
A registry of the available System.Type of message-provider services.
Inheritance
Implements
Inherited Members
Namespace: CSF.Validation.Messages
Assembly: CSF.Validation.dll
Syntax
public class MessageProviderRegistry : IGetsCandidateMessageTypes
Remarks
A message provider service is class which implements one of the following interfaces. It is OK if a single class implements more of these interfaces. It is also acceptable if it implements more than one closed generic form of either (or both) of the generic interfaces.
The class may optionally also implement any (or all) of the following, again perhaps implementing multiple closed generic forms of the same generic interface an unlimited number of times.
- IHasFailureMessageUsageCriteria
- IHasFailureMessageUsageCriteria<TValidated>
- IHasFailureMessageUsageCriteria<TValidated, TParent>
The implementation of this service should be registered in dependency injection as a singleton.
Constructors
| Improve this Doc View SourceMessageProviderRegistry(IGetsRuleMatchingInfoForMessageProviderType, IOptions<MessageProviderTypeOptions>)
Initialises a new instance of MessageProviderRegistry.
Declaration
public MessageProviderRegistry(IGetsRuleMatchingInfoForMessageProviderType matchingInfoProvider, IOptions<MessageProviderTypeOptions> typeOptions)
Parameters
Type | Name | Description |
---|---|---|
IGetsRuleMatchingInfoForMessageProviderType | matchingInfoProvider | A service that gets message provider matching info. |
Microsoft.Extensions.Options.IOptions<MessageProviderTypeOptions> | typeOptions | An options object which indicates the available message provider types. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | If any parameter is null. |
Methods
| Improve this Doc View SourceGetCandidateMessageProviderTypes(ValidationRuleResult)
Gets a collection of message provider types from the registry which are candidates to provide a message for the specified validation rule result.
Declaration
public IEnumerable<MessageProviderTypeInfo> GetCandidateMessageProviderTypes(ValidationRuleResult result)
Parameters
Type | Name | Description |
---|---|---|
ValidationRuleResult | result | A validation rule result. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<MessageProviderTypeInfo> | A collection of candidate message provider types and their priority. |
Remarks
This method does not take into account the CanGetFailureMessage(ValidationRuleResult) method, or any of the equivalent methods upon IHasFailureMessageUsageCriteria<TValidated> or IHasFailureMessageUsageCriteria<TValidated, TParent>. This method only filters/selects candidate types based upon the FailureMessageStrategyAttribute and the predicate values stored there.
Further logic should be executed afterward to determine whether or not the type information provided is suitable to select as the message provider for the specified validation rule result.