Exemplo n.º 1
0
 protected virtual void OnTypeValidationCompleted(TypeValidationEventArgs e)
 {
     if (this.TypeValidationCompleted != null)
     {
         this.TypeValidationCompleted(this, e);
     }
 }
Exemplo n.º 2
0
        private object PerformTypeValidation(CancelEventArgs e)
        {
            object returnValue = null;

            if (this.m_validatingType != null)
            {
                string message = null;
                if ((this.Mask.Length > 0) && !this.MaskedTextProvider.MaskCompleted)
                {
                    message = MaskInputIncompleteMsg;
                }
                else
                {
                    try
                    {
                        returnValue = this.ValidateType(this.MaskedTextProvider.ToString(false, this.m_provider.IncludeLiterals), this.m_validatingType, this.m_formatProvider);
                    }
                    catch (Exception innerException)
                    {
                        if (innerException.InnerException != null)
                        {
                            innerException = innerException.InnerException;
                        }
                        message = innerException.GetType().ToString() + ": " + innerException.Message;
                    }
                }
                bool isValidInput = false;
                if (message == null)
                {
                    isValidInput = true;
                    message      = TypeValidationSucceeded;
                }
                TypeValidationEventArgs args = new TypeValidationEventArgs(this.m_validatingType, isValidInput, returnValue, message);
                this.OnTypeValidationCompleted(args);
                if (e != null)
                {
                    e.Cancel = args.Cancel;
                }
            }
            return(returnValue);
        }