Ejemplo n.º 1
0
            static Inner()
            {
                try {
                    if (System.IO.File.Exists(DataManager.Instance.DataFile))
                    {
                        SINGLETON = Serialize.DeserializeBinaryFromDisk <GeoData>(DataManager.Instance.DataFile);
                    }
                    else
                    {
                        SINGLETON = Serialize.DeserializeBinaryFromResource <GeoData>("GeoDataSource.GeoDataSource.dat");
                    }

                    if (SINGLETON == null)
                    {
                        throw new ApplicationException("Unable to deserialize dat file");
                    }

                    {
                        Dictionary <string, Country> iso2Map = (from c in SINGLETON.Countries
                                                                where c != null && !string.IsNullOrWhiteSpace(c.ISOAlpha2)
                                                                group c by c.ISOAlpha2 into cg
                                                                select cg).ToDictionary(g => g.Key.ToLower().Trim(), g => g.FirstOrDefault());
                        SINGLETON.LinkNamesInfos(iso2Map);
                        SINGLETON.LinkPostalInfos(iso2Map);
                    }
                    SINGLETON.BuildPostalHash();
                }
                catch (Exception ex)
                {
                    _logger.Fatal("Inner static CTOR", ex);
                    throw;
                }
            }