public static void ValidateRepeaterControl(ResolvedTreeRoot resolvedTreeRoot)
        {
            ValidateAddTaskControlBindings(resolvedTreeRoot);

            DotHtmlCommonValidator.CheckControlTypeCount <Repeater>(resolvedTreeRoot, 1);

            var repeater = resolvedTreeRoot.GetDescendantControls <Repeater>().Single();

            DotHtmlCommonValidator.ValidatePropertyBinding(resolvedTreeRoot, CreateStep6Property());

            DotHtmlCommonValidator.CheckCountOfHtmlTag(resolvedTreeRoot, "div", 1);

            IAbstractPropertySetter setter;

            if (!repeater.TryGetProperty(Repeater.ItemTemplateProperty, out setter) ||
                !(setter is ResolvedPropertyTemplate))
            {
                throw new CodeValidationException(Lesson2Texts.RepeaterTemplateMissingDivError);
            }
            var template = (ResolvedPropertyTemplate)setter;

            var div = template.GetDescendantControls <HtmlGenericControl>().ToList();

            if (div.Count(d => d.DothtmlNode.As <DothtmlElementNode>()?.TagName == "div") != 1)
            {
                throw new CodeValidationException(Lesson2Texts.RepeaterTemplateMissingDivError);
            }
        }
예제 #2
0
        public void Validate(ResolvedTreeRoot resolvedTreeRoot)
        {
            Lesson3CommonValidator.CheckStep11Controls(resolvedTreeRoot);
            DotHtmlCommonValidator.CheckCountOfHtmlTag(resolvedTreeRoot, "div", 1);

            DotHtmlCommonValidator.ValidatePropertiesBindings(resolvedTreeRoot, Lesson3CommonValidator.CreateStep14Properties());
        }
예제 #3
0
        public void Validate(ResolvedTreeRoot resolvedTreeRoot)
        {
            DotHtmlCommonValidator.CheckCountOfHtmlTag(resolvedTreeRoot, "div", 3);
            Lesson4CommonValidator.ValidateStep2ValidationProperties(resolvedTreeRoot);
            Lesson4CommonValidator.ValidateOnlyStep3Properties(resolvedTreeRoot);

            var property = new Property("has-error", "none", ControlBindName.DivValidatorInvalidCssClass);

            DotHtmlCommonValidator.ValidatePropertyBinding(resolvedTreeRoot, property);

            var invalidCssException = new CodeValidationException(Lesson4Texts.AllDivsMustHaveInvalidCssClass);

            DotHtmlCommonValidator.CheckCountOfHtmlTagWithPropertyDescriptor(resolvedTreeRoot, "div", 3, Validator.InvalidCssClassProperty, invalidCssException);
        }
        public static void ValidateStep5(ResolvedTreeRoot resolvedTreeRoot)
        {
            var divEnwrapException = new CodeValidationException(Lesson4Texts.WrapDivsInForm);

            DotHtmlCommonValidator.CheckCountOfHtmlTag(resolvedTreeRoot, "form", 1, divEnwrapException);

            var property = new Property("has-error", "fakeProp", ControlBindName.FormValidatorInvalidCssClass);

            DotHtmlCommonValidator.ValidatePropertyBinding(resolvedTreeRoot, property);

            var contentNode = resolvedTreeRoot.GetDescendantControls <HtmlGenericControl>().
                              FirstOrDefault(d => d.DothtmlNode.As <DothtmlElementNode>()?.TagName == "form");

            DotHtmlCommonValidator.CheckCountOfHtmlTag(contentNode, "div", 3);

            var redundantInvalidCssException = new CodeValidationException(Lesson4Texts.ChildDivsDontNeedInvalidCssClassAnymore);

            ValidateStep2ValidationProperties(contentNode);
            DotHtmlCommonValidator.CheckCountOfHtmlTagWithPropertyDescriptor(contentNode, "div", 0, Validator.InvalidCssClassProperty, redundantInvalidCssException);

            property.TargetControlBindName = ControlBindName.DivValidatorInvalidCssClassRemove;
            DotHtmlCommonValidator.ValidatePropertyBinding(contentNode, property);
        }
 public void Validate(ResolvedTreeRoot resolvedTreeRoot)
 {
     DotHtmlCommonValidator.CheckCountOfHtmlTag(resolvedTreeRoot, "div", 3);
     Lesson4CommonValidator.ValidateStep2ValidationProperties(resolvedTreeRoot);
     Lesson4CommonValidator.ValidateOnlyStep3Properties(resolvedTreeRoot);
 }