예제 #1
0
        //---------------------------------------------------------------------
        private static void Initialize()
        {
            string   dsn      = null;
            Database database = null;

            try
            {
                // create the converters
                m_raceConverter = ConverterFactory.Create(ConverterFactory.SCHEMA_RACE);
                m_punyConverter = ConverterFactory.Create(ConverterFactory.SCHEMA_PUNYCODE);

                // Load the tld cache
                dsn      = ConfigurationSettings.AppSettings["dsn"];
                database = new Database(dsn);

                // load the tld cache.
                m_tldCache = database.GetTldCache();
            }
            catch (SqlException e)
            {
                // sql exception, load cache from local file
                LoadLocalCache();
                EventLogger.Log(EVENT_SOURCE, EventLogger.LogType.Error, "Load tld Cache from database failed\r\n" + e.ToString());
            }
        }
예제 #2
0
        //---------------------------------------------------------------------
        // Static method
        //---------------------------------------------------------------------
        public static IACEConverter Create(string pSchema)
        {
            IACEConverter converter = null;

            try
            {
                // valid?
                if (null != pSchema)
                {
                    pSchema = pSchema.ToUpper();
                }

                // create converter
                switch (pSchema)
                {
                case SCHEMA_RACE:
                    converter = new ACEConverter(StringPrep.GetInstance(), new RaceConverter());
                    break;

                case SCHEMA_PUNYCODE:
                    converter = new ACEConverter(StringPrep.GetInstance(), new PunyConverter());
                    break;

                default:
                    converter = null;
                    break;
                }
            }
            catch (Exception)
            {
                converter = null;
            }

            // Done
            return(converter);
        }