Exemplo n.º 1
0
 /// <summary>
 /// Adds a ValidationMapping to the ValidationMap that establishes a validation criteria that needs to be met for the
 /// specified indicator
 /// </summary>
 /// <param name="indicatorName">The indicator to add a validation rule for</param>
 /// <param name="mapping">ValidationMapping that builds the ValidationRule</param>
 public void AddToMap(string indicatorName, ValidationMapping mapping)
 {
     if (ValidationMap != null)
     {
         if (!ValidationMap.ContainsKey(indicatorName))
         {
             ValidationMap.Add(indicatorName, new List<ValidationMapping>());
         }
         // Add the new mapping
         ValidationMap[indicatorName].Add(mapping);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Builds an instance of a ValidationRule
 /// </summary>
 /// <param name="mapping">The ValidationMapping</param>
 /// <param name="indicator">The indicator to validate gainst</param>
 /// <param name="values">The values to validate against</param>
 /// <returns></returns>
 public static ValidationRule BuildRule(ValidationMapping mapping, Indicator indicator, List<IndicatorValue> values)
 {
     switch (mapping.ValidationType)
     {
         case ValidationRuleType.GreaterThanSum:
             return new GreaterThanSumRule(indicator, values, mapping.IndicatorsToCompareAgainst.ToList());
         case ValidationRuleType.GreaterThanEqualToSum:
             return new GreaterThanEqualToSumRule(indicator, values, mapping.IndicatorsToCompareAgainst.ToList());
         case ValidationRuleType.LessThanSum:
             return new LessThanSumRule(indicator, values, mapping.IndicatorsToCompareAgainst.ToList());
         case ValidationRuleType.LessThanEqualToSum:
             return new LessThanEqualToSumRule(indicator, values, mapping.IndicatorsToCompareAgainst.ToList());
         case ValidationRuleType.EqualToSum:
             return new EqualToSumRule(indicator, values, mapping.IndicatorsToCompareAgainst.ToList());
         case ValidationRuleType.DateEarlierThan:
             return new DateEarlierThanRule(indicator, values, mapping.IndicatorsToCompareAgainst.ToList());
         case ValidationRuleType.DateLaterThan:
             return new DateLaterThanRule(indicator, values, mapping.IndicatorsToCompareAgainst.ToList());
         case ValidationRuleType.DateHasSameYear:
             return new DateHasSameYearRule(indicator, values, mapping.IndicatorsToCompareAgainst.ToList());
         default:
             return null;
     }
 }