PhoneNumbers.NumberFormat.Builder.SetFormat C# (CSharp) Method

SetFormat() public method

public SetFormat ( string value ) : Builder
value string
return Builder
            public Builder SetFormat(string value)
            {
                if(value == null) throw new global::System.ArgumentNullException("value");
                result.hasFormat = true;
                result.format_ = value;
                return this;
            }

Usage Example

        /**
         * Extracts the pattern for international format. If there is no intlFormat, default to using the
         * national format. If the intlFormat is set to "NA" the intlFormat should be ignored.
         *
         * @throws  RuntimeException if multiple intlFormats have been encountered.
         * @return  whether an international number format is defined.
         */
        public static bool LoadInternationalFormat(PhoneMetadata.Builder metadata,
                                                   XElement numberFormatElement,
                                                   string nationalFormat)
        {
            var intlFormat = new NumberFormat.Builder();

            SetLeadingDigitsPatterns(numberFormatElement, intlFormat);
            intlFormat.SetPattern(numberFormatElement.GetAttribute(PATTERN));
            var intlFormatPattern            = numberFormatElement.GetElementsByTagName(INTL_FORMAT).ToList();
            var hasExplicitIntlFormatDefined = false;

            if (intlFormatPattern.Count > 1)
            {
                throw new Exception("Invalid number of intlFormat patterns for country: " +
                                    metadata.Id);
            }
            if (intlFormatPattern.Count == 0)
            {
                // Default to use the same as the national pattern if none is defined.
                intlFormat.SetFormat(nationalFormat);
            }
            else
            {
                var intlFormatPatternValue = intlFormatPattern.First().Value;
                intlFormat.SetFormat(intlFormatPatternValue);
                hasExplicitIntlFormatDefined = true;
            }

            if (intlFormat.HasFormat)
            {
                metadata.AddIntlNumberFormat(intlFormat);
            }
            return(hasExplicitIntlFormatDefined);
        }
All Usage Examples Of PhoneNumbers.NumberFormat.Builder::SetFormat