Esempio n. 1
0
 /// <summary>
 /// Raises the <see cref="ServerDependencyCheck"/> event.
 /// </summary>
 /// <param name="e"><see cref="DependencyCheckEventArgs"/> </param>
 /// <include file='ValidatorBase.xml' path='ValidatorBase/doc[@name="OnServerDependencyCheck"]/*'/>
 private void OnServerDependencyCheck(DependencyCheckEventArgs e)
 {
     if (this.ServerDependencyCheck != null)
     {
         ServerDependencyCheck(this, e);
     }
 }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ctlInputControl"></param>
        /// <returns>true if dependency check succeeds</returns>
        internal bool PerformDependencyCheck(InputControlBase ctlInputControl)
        {
            bool             bNeedsToBeValidated;
            InputControlBase ctlDependsOn;

            switch (this.DependsOnState)
            {
            case DependsOnState.Checked:
                // Validate only of value is non empty
                ctlDependsOn        = GetDependsOnControl(ctlInputControl);
                bNeedsToBeValidated = !string.IsNullOrWhiteSpace(ctlDependsOn.Value);
                break;

            case DependsOnState.Unchecked:
                // Validate only if value is empty
                ctlDependsOn        = GetDependsOnControl(ctlInputControl);
                bNeedsToBeValidated = string.IsNullOrWhiteSpace(ctlDependsOn.Value);
                break;

            case DependsOnState.Value:
                ctlDependsOn        = GetDependsOnControl(ctlInputControl);
                bNeedsToBeValidated = ctlDependsOn.Value.Trim() == this.DependsOnValue;
                break;

            case DependsOnState.AnyValue:
                ctlDependsOn        = GetDependsOnControl(ctlInputControl);
                bNeedsToBeValidated = this.DependsOnValue.Contains(ctlDependsOn.Value.Trim());
                break;

            case DependsOnState.Selector:
            case DependsOnState.Custom:
                DependencyCheckEventArgs args = new DependencyCheckEventArgs
                {
                    ControlToValidate = ctlInputControl
                };
                OnServerDependencyCheck(args);
                bNeedsToBeValidated = args.NeedsToBeValdiated;
                break;

            case DependsOnState.NotSet:
                bNeedsToBeValidated = false;
                break;

            default:
                throw new NotImplementedException();
            }
            return(bNeedsToBeValidated);
        }