System.ComponentModel.MaskedTextProvider.MaskedTextProvider C# (CSharp) Method

MaskedTextProvider() public method

Creates a MaskedTextProvider object from the specified mask. 'culture' is used to set the separator characters to the correspondig locale character; if null, the current culture is used. 'allowPromptAsInput' specifies whether the prompt character should be accepted as a valid input or not. 'promptChar' specifies the character to be used for the prompt. 'passwordChar' specifies the character to be used in the password string. 'restrictToAscii' specifies whether the input characters should be restricted to ASCII characters only.
public MaskedTextProvider ( string mask, CultureInfo culture, bool allowPromptAsInput, char promptChar, char passwordChar, bool restrictToAscii ) : System
mask string
culture System.Globalization.CultureInfo
allowPromptAsInput bool
promptChar char
passwordChar char
restrictToAscii bool
return System
        public MaskedTextProvider(string mask, CultureInfo culture, bool allowPromptAsInput, char promptChar, char passwordChar, bool restrictToAscii)
        {
            if (string.IsNullOrEmpty(mask))
            {
                throw new ArgumentException(SR.Format(SR.MaskedTextProviderMaskNullOrEmpty), nameof(mask));
            }

            foreach (char c in mask)
            {
                if (!IsPrintableChar(c))
                {
                    throw new ArgumentException(SR.MaskedTextProviderMaskInvalidChar);
                }
            }

            if (culture == null)
            {
                culture = CultureInfo.CurrentCulture;
            }

            _flagState = new BitVector32();

            // read only property-backend fields.

            _mask = mask;
            _promptChar = promptChar;
            _passwordChar = passwordChar;

            //Neutral cultures cannot be queried for culture-specific information.
            if (culture.IsNeutralCulture)
            {
                // find the first specific (non-neutral) culture that contains country/region specific info.
                foreach (CultureInfo tempCulture in CultureInfo.GetCultures(CultureTypes.SpecificCultures))
                {
                    if (culture.Equals(tempCulture.Parent))
                    {
                        _culture = tempCulture;
                        break;
                    }
                }

                // Last resort use invariant culture.
                if (_culture == null)
                {
                    _culture = CultureInfo.InvariantCulture;
                }
            }
            else
            {
                _culture = culture;
            }

            if (!_culture.IsReadOnly)
            {
                _culture = CultureInfo.ReadOnly(_culture);
            }

            _flagState[s_ALLOW_PROMPT_AS_INPUT] = allowPromptAsInput;
            _flagState[s_ASCII_ONLY] = restrictToAscii;

            // set default values for read/write properties.

            _flagState[s_INCLUDE_PROMPT] = false;
            _flagState[s_INCLUDE_LITERALS] = true;
            _flagState[s_RESET_ON_PROMPT] = true;
            _flagState[s_SKIP_SPACE] = true;
            _flagState[s_RESET_ON_LITERALS] = true;

            Initialize();
        }

Same methods

MaskedTextProvider::MaskedTextProvider ( string mask ) : System
MaskedTextProvider::MaskedTextProvider ( string mask, CultureInfo culture ) : System
MaskedTextProvider::MaskedTextProvider ( string mask, CultureInfo culture, bool restrictToAscii ) : System
MaskedTextProvider::MaskedTextProvider ( string mask, CultureInfo culture, char passwordChar, bool allowPromptAsInput ) : System
MaskedTextProvider::MaskedTextProvider ( string mask, bool restrictToAscii ) : System
MaskedTextProvider::MaskedTextProvider ( string mask, char passwordChar, bool allowPromptAsInput ) : System