Class FailureMessageProviderSelector
A service which can get the appropriate failure message provider for a specified ValidationRuleResult.
Inheritance
Implements
Inherited Members
Namespace: CSF.Validation.Messages
Assembly: CSF.Validation.dll
Syntax
public class FailureMessageProviderSelector : IGetsFailureMessageProvider
Constructors
| Improve this Doc View SourceFailureMessageProviderSelector(IGetsMessageProviderInfoFactory)
Initialises a new instance of FailureMessageProviderSelector.
Declaration
public FailureMessageProviderSelector(IGetsMessageProviderInfoFactory providerInfoFactoryFactory)
Parameters
Type | Name | Description |
---|---|---|
IGetsMessageProviderInfoFactory | providerInfoFactoryFactory | A factory service that gets the message provider info factory. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | If |
Methods
| Improve this Doc View SourceGetProvider(ValidationRuleResult)
Gets the most appropriate message provider implementation for getting a feedback message for the specified ValidationRuleResult.
Declaration
public IGetsFailureMessage GetProvider(ValidationRuleResult ruleResult)
Parameters
Type | Name | Description |
---|---|---|
ValidationRuleResult | ruleResult | The validation rule result for which to get a message provider. |
Returns
Type | Description |
---|---|
IGetsFailureMessage | Either an implementation of IGetsFailureMessage, or a null reference, if no message provider is suitable for the result. |
Remarks
This method uses an instance of IGetsMessageProviderInfo to get a collection of candidate MessageProviderInfo instances which could provide a message for the specified rule result. Once the message provider infos are retrieved, the provider with the highest numeric Priority is selected and its MessageProvider implementation is returned as the result of this method.
If this method returns a null reference then this indicates that there is no message provider suitable for providing the message for the specified rule result. If the IGetsMessageProviderInfo returned more than one MessageProviderInfo which are tied for the highest priority then any of these may be returned by this method, and results might not be stable. Developers are encouraged to avoid message providers with tied priorities.
The instance of IGetsMessageProviderInfo used is retrieved using a IGetsMessageProviderInfoFactory.