public static void Inicializa(Assembly[] arAs, string fileName)
        {
            Castle.ActiveRecord.Framework.Config.XmlConfigurationSource source = new Castle.ActiveRecord.Framework.Config.XmlConfigurationSource(fileName);
            Type[] ar = new Type[] { typeof(string) };

            ActiveRecordStarter.Initialize(arAs, source, ar);
        }
示例#2
0
        private void switchDB()
        {
            ActiveRecordStarter.ResetInitializationFlag();

            // 获取数据库连接配置
            IConfigurationSource source = new Castle.ActiveRecord.Framework.Config.XmlConfigurationSource("../../TestCases/ActiveRecordConfig_1.xml");

            // 载入程序集中所有 ActiveRecord 类。
            ActiveRecordStarter.Initialize(source, typeof(ActiveRecordBase), typeof(TestBase1), typeof(TestBase2),
                                           typeof(Question), typeof(UserData), typeof(User1), typeof(User2));
        }
示例#3
0
        public void setDBConfig()
        {
            Type type = Type.GetType("ActiveRecordTest.Model.TestBase1", false, false);

            String myAssemblyName = Assembly.GetExecutingAssembly().FullName;

            //XmlDocument xmlDoc = new XmlDocument();
            //xmlDoc.Load("../../TestCases/ActiveRecordConfig.xml");
            //xmlDoc.DocumentElement.
            String xmlPath;

            if (dataBaseName.Equals("logical"))
            {
                xmlPath = @"../../TestCases/logicalConfig.xml";
            }
            else if (dataBaseName.Equals("yuwen"))
            {
                xmlPath = @"../../TestCases/yuwenConfig.xml";
            }
            else if (dataBaseName.Equals("math"))
            {
                xmlPath = @"../../TestCases/mathConfig.xml";
            }
            else if (dataBaseName.Equals("erws"))
            {
                xmlPath = @"../../TestCases/erwsConfig.xml";
            }
            else
            {
                //xmlPath = @"../../TestCases/ActiveRecordConfig.xml";
                xmlPath = @"../../TestCases/" + dataBaseName + @"Config.xml";
            }

            XDocument xDoc = null;

            if (File.Exists(xmlPath))
            {
                xDoc = XDocument.Load(xmlPath);
                dataBaseNameInput.Text = "logical Loaded";
            }
            else
            {
                MessageBox.Show(xmlPath + @"该文件不存在,请确认文件及对应数据库已经创建");
                Environment.Exit(0);
            }



            var query = from xElement in xDoc.Descendants("config")
                        where xElement.HasAttributes == false
                        select(from xElement1 in xElement.Descendants("add")
                               where xElement1.Attribute("key").Value == "connection.connection_string"
                               select xElement1).First();

            XElement findXdoc = query.First();

            // 获取数据库连接配置
            //IConfigurationSource source = new Castle.ActiveRecord.Framework.Config.XmlConfigurationSource("../../TestCases/ActiveRecordConfig.xml");

            IConfigurationSource source = new Castle.ActiveRecord.Framework.Config.XmlConfigurationSource(xmlPath);


            // 载入程序集中所有 ActiveRecord 类。
            ActiveRecordStarter.Initialize(source, typeof(ActiveRecordBase), typeof(TestBase1), typeof(TestBase2),
                                           typeof(Question), typeof(UserData), typeof(User1), typeof(User2));

            // 删除数据库架构
            //Castle.ActiveRecord.ActiveRecordStarter.DropSchema();

            // 创建数据库架构(该方法会删除同名表后再创建)
            //Castle.ActiveRecord.ActiveRecordStarter.CreateSchema();
        }
示例#4
0
        private void onStartUp(object sender, StartupEventArgs e)
        {
            IConfigurationSource source = new Castle.ActiveRecord.Framework.Config.XmlConfigurationSource("../../TestCases/ActiveRecordConfig.xml");

            ActiveRecordStarter.Initialize(source, typeof(WordRES), typeof(WordLogic));
        }