Ejemplo n.º 1
0
        public void Validate(ControllerContext controllerContext, ModelValidationNode parentNode)
        {
            if (controllerContext == null)
            {
                throw new ArgumentNullException("controllerContext");
            }

            if (SuppressValidation)
            {
                // no-op
                return;
            }

            // pre-validation steps
            ModelValidatingEventArgs validatingEventArgs = new ModelValidatingEventArgs(controllerContext, parentNode);

            OnValidating(validatingEventArgs);
            if (validatingEventArgs.Cancel)
            {
                return;
            }

            ValidateChildren(controllerContext);
            ValidateThis(controllerContext, parentNode);

            // post-validation steps
            ModelValidatedEventArgs validatedEventArgs = new ModelValidatedEventArgs(controllerContext, parentNode);

            OnValidated(validatedEventArgs);
        }
 private void OnValidating(ModelValidatingEventArgs e)
 {
     EventHandler<ModelValidatingEventArgs> handler = Validating;
     if (handler != null)
     {
         handler(this, e);
     }
 }
Ejemplo n.º 3
0
        private void OnValidating(ModelValidatingEventArgs e)
        {
            EventHandler <ModelValidatingEventArgs> handler = Validating;

            if (handler != null)
            {
                handler(this, e);
            }
        }
        public void Validate(ControllerContext controllerContext, ModelValidationNode parentNode)
        {
            if (controllerContext == null)
            {
                throw new ArgumentNullException("controllerContext");
            }

            if (SuppressValidation)
            {
                // no-op
                return;
            }

            // pre-validation steps
            ModelValidatingEventArgs validatingEventArgs = new ModelValidatingEventArgs(controllerContext, parentNode);
            OnValidating(validatingEventArgs);
            if (validatingEventArgs.Cancel)
            {
                return;
            }

            ValidateChildren(controllerContext);
            ValidateThis(controllerContext, parentNode);

            // post-validation steps
            ModelValidatedEventArgs validatedEventArgs = new ModelValidatedEventArgs(controllerContext, parentNode);
            OnValidated(validatedEventArgs);
        }