Esempio n. 1
0
        static DBContext()
        {
            DefaultListMaxSize = 100;
            Config             = new PeanutSection();
            PeanutSection setting = (PeanutSection)System.Configuration.ConfigurationManager.GetSection("peanut");

            if (setting != null)
            {
                foreach (ConnectionElement item in setting.Connections)
                {
                    Config.Connections.Add(item);
                }
                foreach (AssemblyElement item in setting.Assemblies)
                {
                    Config.Assemblies.Add(item);
                }
                Config.InitHandler = setting.InitHandler;
            }
            for (int i = Config.Connections.Count; i < 1000; i++)
            {
                Config.Connections.Add(new ConnectionElement(i.ToString(), "Peanut.MSSQL,Peanut", ""));
            }
            if (!string.IsNullOrEmpty(Config.InitHandler))
            {
                Type inittype = Type.GetType(Config.InitHandler);
                IDBContextInithandler handler = (IDBContextInithandler)Activator.CreateInstance(inittype);
                handler.Init();
            }
            LoadEntity();
        }
Esempio n. 2
0
 static void LoadEntity()
 {
     if (Config != null)
     {
         Assembly assembly;
         foreach (AssemblyElement ae in Config.Assemblies)
         {
             assembly = Assembly.Load(ae.Type);
             LoadEntityByAssembly(assembly);
         }
     }
     else
     {
         Config = new PeanutSection(30);
     }
 }