public static void ValidateRepeaterTemplate1(ResolvedTreeRoot root)
        {
            ValidateRepeaterControl(root);

            DotHtmlCommonValidator.ValidatePropertyBinding(root, CreateStep5TitleProperty());
            DotHtmlCommonValidator.CheckControlTypeCountInRepeater <LinkButton>(root, 1);
        }
        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);
            }
        }
        public static void ValidateAddTaskControlBindings(ResolvedTreeRoot root)
        {
            ValidateAddTaskControls(root);

            DotHtmlCommonValidator.ValidatePropertyBinding(root, CreateStep3Property());

            root.GetDescendantControls <Button>().Single()
            .ValidateCommandBindingExpression(ButtonBase.ClickProperty, "AddTask()");
        }
Esempio n. 4
0
        public void Validate(ResolvedTreeRoot resolvedTreeRoot)
        {
            Lesson4CommonValidator.ValidateStep5(resolvedTreeRoot);
            DotHtmlCommonValidator.CheckControlTypeCount <Validator>(resolvedTreeRoot, 1);

            DotHtmlCommonValidator.ValidatePropertyBinding(resolvedTreeRoot,
                                                           Lesson4CommonValidator.CreateStep7ValidatorEmail());
            var property = new Property("True", "fakeProp", ControlBindName.ValidatorShowErrorMessageText);

            DotHtmlCommonValidator.ValidatePropertyBinding(resolvedTreeRoot, property);
        }
Esempio n. 5
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);
        }