コード例 #1
0
        public void Validate(CSharpCompilation compilation, CSharpSyntaxTree tree, SemanticModel model,
                             Assembly assembly)
        {
            Lesson4CommonValidator.ValidateStep12(tree, model, assembly);


            ValidatorsExtensions.ExecuteSafe(() =>
            {
                var viewModel = (dynamic)assembly.CreateInstance("DotvvmAcademy.Tutorial.ViewModels.Lesson4ViewModel");

                var now = DateTime.UtcNow;

                viewModel.SubscriptionFrom = now.AddDays(3);
                viewModel.SubscriptionTo   = now;

                IEnumerable <ValidationResult> validationResults = viewModel.Validate(null);
                if (!validationResults.Any())
                {
                    throw new CodeValidationException(Lesson4Texts.IncorrectValidationRule);
                }
                viewModel.SubscriptionFrom = now;
                viewModel.SubscriptionTo   = now.AddDays(5);

                validationResults = viewModel.Validate(null);
                if (validationResults.Any())
                {
                    throw new CodeValidationException(Lesson4Texts.IncorrectValidationRule);
                }
            });
        }
コード例 #2
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);
        }
コード例 #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);
        }
コード例 #4
0
 public void Validate(CSharpCompilation compilation, CSharpSyntaxTree tree, SemanticModel model,
                      Assembly assembly)
 {
     Lesson4CommonValidator.ValidateStep12(tree, model, assembly);
 }
コード例 #5
0
 public void Validate(ResolvedTreeRoot resolvedTreeRoot)
 {
     Lesson4CommonValidator.ValidateStep5(resolvedTreeRoot);
 }
コード例 #6
0
 public void Validate(ResolvedTreeRoot resolvedTreeRoot)
 {
     DotHtmlCommonValidator.CheckCountOfHtmlTag(resolvedTreeRoot, "div", 3);
     Lesson4CommonValidator.ValidateStep2ValidationProperties(resolvedTreeRoot);
     Lesson4CommonValidator.ValidateOnlyStep3Properties(resolvedTreeRoot);
 }