Esempio n. 1
0
        private static IValidatorRule Parse(
            IEnumerable <ExtensibleType_Type_Group> rules,
            Dictionary <string, object> objectStorage,
            Enumerations.JunctionEnum junctionEnum) // throws CertificateValidationException
        {
            List <IValidatorRule> ruleList = new List <IValidatorRule>();

            foreach (ExtensibleType_Type_Group rule in rules)
            {
                ruleList.Add(Parse(rule, objectStorage));

                if (junctionEnum == Enumerations.JunctionEnum.AND)
                {
                    return(Junction.And(ruleList.ToArray()));
                }

                if (junctionEnum == Enumerations.JunctionEnum.OR)
                {
                    return(Junction.Or(ruleList.ToArray()));
                }

                // if (junctionEnum == JunctionEnum.XOR)
                return(Junction.Xor(ruleList.ToArray()));
            }

            throw new InvalidOperationException("Rules list cannot be empty");
        }
Esempio n. 2
0
        /// <summary>
        /// Generates a ValidatorHelper instance containing defined validator(s).
        /// </summary>
        /// <returns>Validator ready for use.</returns>
        public Validator Build()
        {
            if (this.validatorRules.Count == 1)
            {
                return(new Validator(this.validatorRules[0]));
            }

            return(new Validator(Junction.And(this.validatorRules.ToArray())));
        }