PhoneNumbers.PhoneMetadataCollection.Builder.AddMetadata C# (CSharp) Method

AddMetadata() public method

public AddMetadata ( global value ) : Builder
value global
return Builder
            public Builder AddMetadata(global::PhoneNumbers.PhoneMetadata value)
            {
                if(value == null) throw new global::System.ArgumentNullException("value");
                result.metadata_.Add(value);
                return this;
            }

Usage Example

示例#1
0
        // Build the PhoneMetadataCollection from the input XML file.
        public static PhoneMetadataCollection BuildPhoneMetadataCollection(string name,
                                                                           bool liteBuild, bool specialBuild, bool isShortNumberMetadata,
                                                                           bool isAlternateFormatsMetadata)
        {
            XDocument document;

#if (NET35 || NET40)
            var asm = Assembly.GetExecutingAssembly();
#else
            var asm = typeof(PhoneNumberUtil).GetTypeInfo().Assembly;
#endif
            using (var input = asm.GetManifestResourceStream(name))
            {
#if NET35
                document = XDocument.Load(new XmlTextReader(input));
#else
                document = XDocument.Load(input);
#endif
            }

            var metadataCollection = new PhoneMetadataCollection.Builder();
            var metadataFilter     = GetMetadataFilter(liteBuild, specialBuild);
            foreach (var territory in document.GetElementsByTagName("territory"))
            {
                // For the main metadata file this should always be set, but for other supplementary data
                // files the country calling code may be all that is needed.
                var regionCode = territory.GetAttribute("id");
                var metadata   = LoadCountryMetadata(regionCode, territory,
                                                     isShortNumberMetadata, isAlternateFormatsMetadata);
                metadataFilter.FilterMetadata(metadata);
                metadataCollection.AddMetadata(metadata);
            }
            return(metadataCollection.Build());
        }
All Usage Examples Of PhoneNumbers.PhoneMetadataCollection.Builder::AddMetadata