示例#1
0
        private void BuildRuleNode(RuleSetNode ruleNode, ValidationRulesetData rule)
        {
            SelfNode selfNode = new SelfNode();

            ruleNode.AddNode(selfNode);

            AddValidatorNodes(selfNode, rule.Validators);

            foreach (ValidatedFieldReference fieldReference in rule.Fields)
            {
                FieldNode fieldNode = new FieldNode(fieldReference);
                AddValidatorNodes(fieldNode, fieldReference.Validators);

                ruleNode.AddNode(fieldNode);
            }

            foreach (ValidatedPropertyReference proprtyReference in rule.Properties)
            {
                PropertyNode propertyNode = new PropertyNode(proprtyReference);
                AddValidatorNodes(propertyNode, proprtyReference.Validators);

                ruleNode.AddNode(propertyNode);
            }


            foreach (ValidatedMethodReference methodReference in rule.Methods)
            {
                MethodNode methodNode = new MethodNode(methodReference);
                AddValidatorNodes(methodNode, methodReference.Validators);

                ruleNode.AddNode(methodNode);
            }
        }
示例#2
0
        /// <summary>
        /// <para>Creates an instance of the child node class and adds it as a child of the parent node. The node will be a <see cref="RuleSetNode"/>.</para>
        /// </summary>
        /// <param name="node">
        /// <para>The parent node to add the newly created <see cref="RuleSetNode"/>.</para>
        /// </param>
        protected override void ExecuteCore(ConfigurationNode node)
        {
            base.ExecuteCore(node);

            RuleSetNode ruleNode = ChildNode as RuleSetNode;

            if (ruleNode == null)
            {
                return;
            }

            ruleNode.AddNode(new SelfNode());
        }
示例#3
0
        private void BuildMethodReferences(ValidationRulesetData validationRule, RuleSetNode ruleNode)
        {
            foreach (MethodNode methodNode in ruleNode.Hierarchy.FindNodesByType(ruleNode, typeof(MethodNode)))
            {
                ValidatedMethodReference methodReference = new ValidatedMethodReference();
                methodReference.Name = methodNode.Name;

                foreach (ValidatorData validator in FindValidators(methodNode))
                {
                    methodReference.Validators.Add(validator);
                }

                validationRule.Methods.Add(methodReference);
            }
        }
示例#4
0
        private void BuildPropertyReferences(ValidationRulesetData validationRule, RuleSetNode ruleNode)
        {
            foreach (PropertyNode propertyNode in ruleNode.Hierarchy.FindNodesByType(ruleNode, typeof(PropertyNode)))
            {
                ValidatedPropertyReference propertyReference = new ValidatedPropertyReference();
                propertyReference.Name = propertyNode.Name;

                foreach (ValidatorData validator in FindValidators(propertyNode))
                {
                    propertyReference.Validators.Add(validator);
                }

                validationRule.Properties.Add(propertyReference);
            }
        }
示例#5
0
        private void BuildFieldReferences(ValidationRulesetData validationRule, RuleSetNode ruleNode)
        {
            foreach (FieldNode fieldNode in ruleNode.Hierarchy.FindNodesByType(ruleNode, typeof(FieldNode)))
            {
                ValidatedFieldReference fieldReference = new ValidatedFieldReference();
                fieldReference.Name = fieldNode.Name;

                foreach (ValidatorData validator in FindValidators(fieldNode))
                {
                    fieldReference.Validators.Add(validator);
                }

                validationRule.Fields.Add(fieldReference);
            }
        }
示例#6
0
        private void BuildTypeNode(TypeNode typeNode, ValidatedTypeReference typeReference)
        {
            foreach (ValidationRulesetData rule in typeReference.Rulesets)
            {
                RuleSetNode ruleNode = new RuleSetNode(rule);

                BuildRuleNode(ruleNode, rule);

                typeNode.AddNode(ruleNode);
                if (string.Compare(typeReference.DefaultRuleset, rule.Name) == 0)
                {
                    typeNode.DefaultRule = ruleNode;
                }
            }
        }
        private void BuildFieldReferences(ValidationRulesetData validationRule, RuleSetNode ruleNode)
        {
            foreach (FieldNode fieldNode in ruleNode.Hierarchy.FindNodesByType(ruleNode, typeof(FieldNode)))
            {
                ValidatedFieldReference fieldReference = new ValidatedFieldReference();
                fieldReference.Name = fieldNode.Name;

                foreach (ValidatorData validator in FindValidators(fieldNode))
                {
                    fieldReference.Validators.Add(validator);
                }

                validationRule.Fields.Add(fieldReference);
            }
        }
示例#8
0
 private void OnDefaultRuleNodeRemoved(object sender, ConfigurationNodeChangedEventArgs e)
 {
     this.defaultRuleNode = null;
     this.defaultRuleName = null;
 }
        private void BuildMethodReferences(ValidationRulesetData validationRule, RuleSetNode ruleNode)
        {
            foreach (MethodNode methodNode in ruleNode.Hierarchy.FindNodesByType(ruleNode, typeof(MethodNode)))
            {
                ValidatedMethodReference methodReference = new ValidatedMethodReference();
                methodReference.Name = methodNode.Name;

                foreach (ValidatorData validator in FindValidators(methodNode))
                {
                    methodReference.Validators.Add(validator);
                }

                validationRule.Methods.Add(methodReference);
            }
        }
        private void BuildPropertyReferences(ValidationRulesetData validationRule, RuleSetNode ruleNode)
        {
            foreach (PropertyNode propertyNode in ruleNode.Hierarchy.FindNodesByType(ruleNode, typeof(PropertyNode)))
            {
                ValidatedPropertyReference propertyReference = new ValidatedPropertyReference();
                propertyReference.Name = propertyNode.Name;

                foreach (ValidatorData validator in FindValidators(propertyNode))
                {
                    propertyReference.Validators.Add(validator);
                }

                validationRule.Properties.Add(propertyReference);
            }
        }
示例#11
0
 private void OnDefaultRuleNodeRemoved(object sender, ConfigurationNodeChangedEventArgs e)
 {
     this.defaultRuleNode = null;
     this.defaultRuleName = null;
 }