Example #1
0
        public static void Initial()
        {
            _loaders.Clear();

            Type[] types = Assembly.GetCallingAssembly().GetTypes();

            Stopwatch sw = new Stopwatch();

            sw.Start();
            for (int i = 0; i < types.Length; ++i)
            {
                Type type = types[i];
                try
                {
                    if (type.GetInterface(typeof(IDBFileLoader).Name) == null)
                    {
                        continue;
                    }

                    IDBFileLoader loader = Activator.CreateInstance(type) as IDBFileLoader;
                    if (loader == null)
                    {
                        throw new InvalidCastException("IDBFileLoader");
                    }

                    loader.Load();
                    _loaders.Add(loader);
                }
                catch (Exception e)
                {
                    Console.WriteLine(Resources.Error_while_loading_db_file, type.Name);
                    Console.WriteLine(e);
                    continue;
                }
            }
            sw.Stop();
            Console.WriteLine(Resources.Loaded_count_db_files, _loaders.Count, sw.ElapsedMilliseconds);
        }