/* OLD */

        /*private static void LoadAlternateFormatsMedataFromFile(string filePrefix)
         * {
         #if (NET35 || NET40)
         *  var asm = Assembly.GetExecutingAssembly();
         #else
         *  var asm = typeof(MetadataManager).GetTypeInfo().Assembly;
         #endif
         *  var name = asm.GetManifestResourceNames().FirstOrDefault(n => n.EndsWith(filePrefix)) ?? "missing";
         *  var meta = BuildMetadataFromXml.BuildPhoneMetadataCollection(name, false, false, false, true); // todo lite/special build
         *  foreach (var m in meta.MetadataList)
         *  {
         *      CallingCodeToAlternateFormatsMap[m.CountryCode] = m;
         *  }
         * }*/

        /* CHANGE */
        private static void LoadAlternateFormatsMedataFromFile(string filePrefix, bool forceEmbedded = false)
        {
            string name;

            if (string.IsNullOrEmpty(PhoneNumberUtil.ExternalResourcesRootDirectory) || forceEmbedded)
            {
#if (NET35 || NET40)
                var asm = Assembly.GetExecutingAssembly();
#else
                var asm = typeof(MetadataManager).GetTypeInfo().Assembly;
#endif
                name = asm.GetManifestResourceNames().FirstOrDefault(n => n.EndsWith(filePrefix)) ?? "missing";
            }
            else
            {
                var files = Directory.GetFiles(PhoneNumberUtil.ExternalResourcesRootDirectory, filePrefix + "*");
                if (files.Length == 0)
                {
                    LoadAlternateFormatsMedataFromFile(filePrefix, true);
                    return;
                }
                name = Path.GetFileName(files[0]);
            }

            var meta = BuildMetadataFromXml.BuildPhoneMetadataCollection(name, false, false, false, true); // todo lite/special build
            foreach (var m in meta.MetadataList)
            {
                CallingCodeToAlternateFormatsMap[m.CountryCode] = m;
            }
        }
        static private void LoadMedataFromFile(String filePrefix)
        {
            var asm  = Redirections.GetAssembly();
            var name = asm.GetManifestResourceNames().FirstOrDefault(n => n.EndsWith(filePrefix)) ?? "missing";

            using (var stream = asm.GetManifestResourceStream(name))
            {
                var meta = BuildMetadataFromXml.BuildPhoneMetadataCollection(stream, false);
                foreach (var m in meta.MetadataList)
                {
                    callingCodeToAlternateFormatsMap[m.CountryCode] = m;
                }
            }
        }
示例#3
0
        private static void LoadShortNumberMedataFromFile(string filePrefix)
        {
#if (NET35 || NET40)
            var asm = Assembly.GetExecutingAssembly();
#else
            var asm = typeof(MetadataManager).GetTypeInfo().Assembly;
#endif
            var name = asm.GetManifestResourceNames().FirstOrDefault(n => n.EndsWith(filePrefix)) ?? "missing";
            var meta = BuildMetadataFromXml.BuildPhoneMetadataCollection(name, false, false, true, false); // todo lite/special build
            foreach (var m in meta.MetadataList)
            {
                ShortNumberMetadataMap[m.Id] = m;
            }
        }
示例#4
0
        private static void LoadMedataFromFile(string filePrefix)
        {
#if NET40
            var asm = Assembly.GetExecutingAssembly();
#else
            var asm = typeof(MetadataManager).GetTypeInfo().Assembly;
#endif
            var name = asm.GetManifestResourceNames().FirstOrDefault(n => n.EndsWith(filePrefix)) ?? "missing";
            using (var stream = asm.GetManifestResourceStream(name))
            {
                var meta = BuildMetadataFromXml.BuildPhoneMetadataCollection(stream, false, false); // todo lite/special build
                foreach (var m in meta.MetadataList)
                {
                    CallingCodeToAlternateFormatsMap[m.CountryCode] = m;
                }
            }
        }
 // A mapping from a country code to the region codes which denote the
 // country/region represented by that country code. In the case of multiple
 // countries sharing a calling code, such as the NANPA countries, the one
 // indicated with "isMainCountryForCode" in the metadata should be first.
 public static Dictionary <int, List <string> > GetCountryCodeToRegionCodeMap()
 {
     return(BuildMetadataFromXml.GetCountryCodeToRegionCodeMap(
                PhoneNumberUtil.MetaDataFilePrefix));
 }
 // A mapping from a country code to the region codes which denote the
 // country/region represented by that country code. In the case of multiple
 // countries sharing a calling code, such as the NANPA countries, the one
 // indicated with "isMainCountryForCode" in the metadata should be first.
 public static Dictionary <int, List <String> > GetCountryCodeToRegionCodeMap()
 {
     return(BuildMetadataFromXml.GetCountryCodeToRegionCodeMap(
                PhoneNumberUtil.META_DATA_FILE_PREFIX));
 }
示例#7
0
 // @VisibleForTesting
 public ShortNumberUtil(PhoneNumberUtil util)
 {
     phoneUtil = util;
     countryCallingCodeToRegionCodeMap =
         BuildMetadataFromXml.GetCountryCodeToRegionCodeMap(MetaDataFilePrefix);
 }
示例#8
0
 public ShortNumberUtil()
 {
     phoneUtil = PhoneNumberUtil.GetInstance();
     countryCallingCodeToRegionCodeMap =
         BuildMetadataFromXml.GetCountryCodeToRegionCodeMap(MetaDataFilePrefix);
 }