ParseAreaCodeMap() public static method

public static ParseAreaCodeMap ( Stream stream ) : AreaCodeMap
stream Stream
return AreaCodeMap
        /* OLD */

        /*private void LoadAreaCodeMapFromFile(string fileName)
         * {
         #if (NET35 || NET40)
         *  var asm = Assembly.GetExecutingAssembly();
         #else
         *  var asm = typeof(PhoneNumberOfflineGeocoder).GetTypeInfo().Assembly;
         #endif
         *  var prefix = asm.GetName().Name + "." + phonePrefixDataDirectory;
         *  var resName = prefix + fileName;
         *  using (var fp = asm.GetManifestResourceStream(resName))
         *  {
         *      var areaCodeMap = AreaCodeParser.ParseAreaCodeMap(fp);
         *      availablePhonePrefixMaps[fileName] = areaCodeMap;
         *  }
         * }*/

        /* CHANGE */
        private void LoadAreaCodeMapFromFile(string fileName, bool forceEmbedded = false)
        {
            if (string.IsNullOrEmpty(PhoneNumberUtil.ExternalResourcesRootDirectory) || forceEmbedded)
            {
#if (NET35 || NET40)
                var asm = Assembly.GetExecutingAssembly();
#else
                var asm = typeof(PhoneNumberOfflineGeocoder).GetTypeInfo().Assembly;
#endif
                var prefix  = asm.GetName().Name + "." + phonePrefixDataDirectory;
                var resName = prefix + fileName;

                using (var fp = asm.GetManifestResourceStream(resName))
                {
                    var areaCodeMap = AreaCodeParser.ParseAreaCodeMap(fp);
                    availablePhonePrefixMaps[fileName] = areaCodeMap;
                }
            }
            else
            {
                var prefix = "prod_";
                var name   = Path.Combine(PhoneNumberUtil.ExternalResourcesRootDirectory, prefix + fileName);
                if (!File.Exists(name))
                {
                    LoadAreaCodeMapFromFile(fileName, true);
                    return;
                }

                using (var fp = new MemoryStream(File.ReadAllBytes(name)))
                {
                    var areaCodeMap = AreaCodeParser.ParseAreaCodeMap(fp);
                    availablePhonePrefixMaps[fileName] = areaCodeMap;
                }
            }
        }
Esempio n. 2
0
        private AreaCodeMap LoadAreaCodeMapFromFile(string fileName)
        {
            var resName = phonePrefixDataDirectory + fileName;

            using (var fp = assembly.GetManifestResourceStream(resName))
            {
                var areaCodeMap = AreaCodeParser.ParseAreaCodeMap(fp);
                return(availablePhonePrefixMaps[fileName] = areaCodeMap);
            }
        }
Esempio n. 3
0
        private void LoadAreaCodeMapFromFile(String fileName)
        {
            var asm     = Assembly.GetExecutingAssembly();
            var prefix  = asm.GetName().Name + "." + phonePrefixDataDirectory;
            var resName = prefix + fileName;

            using (var fp = asm.GetManifestResourceStream(resName))
            {
                var areaCodeMap = AreaCodeParser.ParseAreaCodeMap(fp);
                availablePhonePrefixMaps[fileName] = areaCodeMap;
            }
        }
        private void LoadAreaCodeMapFromFile(String fileName)
        {
            var asm     = typeof(PhoneNumberOfflineGeocoder).GetTypeInfo().Assembly;
            var prefix  = asm.GetName().Name + "." + phonePrefixDataDirectory;
            var resName = prefix + fileName;

            using (var fp = asm.GetManifestResourceStream(resName))
            {
                var areaCodeMap = AreaCodeParser.ParseAreaCodeMap(fp);
                availablePhonePrefixMaps[fileName] = areaCodeMap;
            }
        }