コード例 #1
0
 private static void ValidatePropertyRestriction(Restriction.PropertyRestriction restriction)
 {
     if (!RestrictionEvaluator.IsSupportedOperation(restriction.Op))
     {
         throw new InvalidRuleException(string.Format("Operation {0} is not supported", restriction.Op));
     }
     if (RuleUtil.IsMultiValueTag(restriction.PropValue.PropTag))
     {
         if (restriction.MultiValued)
         {
             throw new InvalidRuleException("At most one tag can be multi-valued");
         }
         if (restriction.Op != Restriction.RelOp.Equal && restriction.Op != Restriction.RelOp.NotEqual)
         {
             throw new InvalidRuleException("Restriction has multi-valued value only support Equal or NotEqual operation");
         }
     }
     if (!RuleUtil.IsSameType(restriction.PropTag, restriction.PropValue.PropTag))
     {
         throw new InvalidRuleException("Tag and value are of different type");
     }
     if (RuleUtil.IsBooleanTag(restriction.PropTag) && restriction.Op != Restriction.RelOp.Equal && restriction.Op != Restriction.RelOp.NotEqual)
     {
         throw new InvalidRuleException("Boolean tag only support Equal or NotEqual operation");
     }
     RestrictionEvaluator.ValidateRestrictionValue(restriction.PropValue);
 }
コード例 #2
0
 private static void ValidateComparePropertyRestriction(Restriction.ComparePropertyRestriction restriction)
 {
     if (!RestrictionEvaluator.IsSupportedOperation(restriction.Op))
     {
         throw new InvalidRuleException(string.Format("Operation {0} is not supported", restriction.Op));
     }
     if (!RuleUtil.IsSameType(restriction.TagLeft, restriction.TagRight))
     {
         throw new InvalidRuleException("Tag and value are of different type");
     }
     if (RuleUtil.IsBooleanTag(restriction.TagLeft) && restriction.Op != Restriction.RelOp.Equal && restriction.Op != Restriction.RelOp.NotEqual)
     {
         throw new InvalidRuleException("Boolean tag only support Equal or NotEqual operation");
     }
     if (RuleUtil.IsMultiValueTag(restriction.TagLeft) || RuleUtil.IsMultiValueTag(restriction.TagRight))
     {
         throw new InvalidRuleException("Multi-valued prop or value is not supported in CompareProperty Restriction");
     }
 }