Ejemplo n.º 1
0
        public void Validate(ResolvedTreeRoot resolvedTreeRoot)
        {
            Lesson2CommonValidator.ValidateRepeaterTemplate3(resolvedTreeRoot);

            var template = resolvedTreeRoot.GetDescendantControls <Repeater>().Single()
                           .Properties[Repeater.ItemTemplateProperty]
                           .CastTo <ResolvedPropertyTemplate>();

            List <ResolvedControl> resolvedControls = template
                                                      .GetDescendantControls <HtmlGenericControl>()
                                                      .ToList();
            var div = resolvedControls.First(d => d.DothtmlNode.As <DothtmlElementNode>()?.TagName == "div");

            List <ResolvedPropertyBinding> divClassProperties = div.Properties
                                                                .Where(p => p.Value.Property.Name == "Attributes:class")
                                                                .Select(p => p.Value)
                                                                .OfType <ResolvedPropertyBinding>()
                                                                .ToList();

            if (divClassProperties.Count != 1)
            {
                throw new CodeValidationException(Lesson2Texts.InvalidClassBinding);
            }

            var classBinding = divClassProperties[0].Binding.Value.Replace(" ", "").Replace("\"", "'");

            if ((classBinding != "IsCompleted?'task-completed':'task'") &&
                (classBinding != "IsCompleted==true?'task-completed':'task'") &&
                (classBinding != "!IsCompleted?'task':'task-completed'") &&
                (classBinding != "IsCompleted==false?'task':'task-completed'"))
            {
                throw new CodeValidationException(Lesson2Texts.InvalidClassExpressionBinding);
            }
        }
Ejemplo n.º 2
0
 public void Validate(ResolvedTreeRoot resolvedTreeRoot)
 {
     Lesson2CommonValidator.ValidateRepeaterTemplate3(resolvedTreeRoot);
 }