public NPetshopContainer() : base() { TypedFactoryFacility facility = new TypedFactoryFacility(); AddFacility("typedfactory", facility); facility.AddTypedFactoryEntry( new FactoryEntry("stateFactory", typeof(IStateFactory), "Create", "Release")); // Add DaoManager bool test = Convert.ToBoolean(ConfigurationSettings.AppSettings["test"]); DomDaoManagerBuilder builder = new DomDaoManagerBuilder(); if (test) { builder.Configure(@"..\..\..\NPetshop.Persistence\dao.config"); } else { builder.Configure(@"..\NPetshop.Persistence\dao.config"); } this.Kernel.AddComponentInstance("DaoManager", typeof(DaoManager), DaoManager.GetInstance("SqlMapDao")); // Add services AddServices(); // Add Controllers AddControllers(); AddMVC(test); }
public void FixtureSetUp() { DomDaoManagerBuilder builder = new DomDaoManagerBuilder(); #if dotnet2 builder.Configure("dao_MySql_" + ConfigurationManager.AppSettings["providerType"] + ".config"); #else builder.Configure("dao_MySql_" + ConfigurationSettings.AppSettings["providerType"] + ".config"); #endif daoManager = DaoManager.GetInstance(); }
private void OnConfigChange(object obj) { if (builder == null) { builder = new DomDaoManagerBuilder(); } builder.Configure(daoConfig); }
public void FixtureSetUp() { DomDaoManagerBuilder builder = new DomDaoManagerBuilder(); builder.Configure("dao_Oracle_" + ConfigurationSettings.AppSettings["providerType"] + ".config"); daoManager = DaoManager.GetInstance(); }
public void FixtureSetUp() { DomDaoManagerBuilder builder = new DomDaoManagerBuilder(); builder.Configure("dao_MSSQL_" + Configuration["providerType"] + ".config"); daoManager = DaoManager.GetInstance(); }
public void FixtureSetUp() { DomDaoManagerBuilder builder = new DomDaoManagerBuilder(); builder.Configure("dao" + "_" + Configuration["database"] + "_" + Configuration["providerType"] + ".config"); daoManager = DaoManager.GetInstance("SqlMapDao"); }
public void SetUp() { DomDaoManagerBuilder builder = new DomDaoManagerBuilder(); builder.Configure(@"..\..\..\NPetshop.Persistence\dao.config"); daoManager = DaoManager.GetInstance("SqlMapDao"); }
public static void LocalDbInit() { try { dal.Configure("dbconfig/dao.config"); } catch { } }
public void SetUp() { DomDaoManagerBuilder builder = new DomDaoManagerBuilder(); builder.Configure("dao" + "_" + ConfigurationSettings.AppSettings["database"] + "_" + ConfigurationSettings.AppSettings["providerType"] + ".config"); daoManager = DaoManager.GetInstance("SqlMapDao"); daoManager2 = DaoManager.GetInstance("NHibernateDao"); InitScript(daoManager.LocalDataSource, ScriptDirectory + "account-init.sql"); InitScript(daoManager2.LocalDataSource, ScriptDirectory + "user-init.sql"); }
public void SetUp() { string scriptDirectory = Path.Combine(Path.Combine(Path.Combine(Path.Combine(Resources.ApplicationBase, ".."), ".."), "Scripts"), ConfigurationSettings.AppSettings["database"]) + Path.DirectorySeparatorChar; // Resources.RootDirectory + Path.DirectorySeparatorChar + // "Scripts" + Path.DirectorySeparatorChar + // ConfigurationSettings.AppSettings["database"]+ Path.DirectorySeparatorChar; DomDaoManagerBuilder builder = new DomDaoManagerBuilder(); builder.Configure("dao" + "_" + ConfigurationSettings.AppSettings["database"] + "_" + ConfigurationSettings.AppSettings["providerType"] + ".config"); _daoManager = DaoManager.GetInstance("NHibernateDao"); InitScript(_daoManager.LocalDataSource, scriptDirectory + "user-init.sql"); }
public void MultipleContext() { DomDaoManagerBuilder builder = new DomDaoManagerBuilder(); builder.Configure("dao_Multiple_Context.config"); IDaoManager daoManager1 = DaoManager.GetInstance("Contex1"); IDaoManager daoManager2 = DaoManager.GetInstance("Contex2"); Assert.IsNotNull(daoManager1); Assert.IsNotNull(daoManager2); Assert.IsTrue(daoManager2.LocalDataSource.ConnectionString != daoManager1.LocalDataSource.ConnectionString); Assert.IsTrue(daoManager2.LocalDataSource.DbProvider.Name != daoManager1.LocalDataSource.DbProvider.Name); daoManager1.OpenConnection(); daoManager2.OpenConnection(); daoManager1.CloseConnection(); daoManager2.CloseConnection(); }
static public ServiceConfig GetInstance() { try { if (_instance == null) { lock (_synRoot) { if (_instance == null) { try { // 读取dao.config Assembly thisExe = Assembly.GetExecutingAssembly(); Stream stream = thisExe.GetManifestResourceStream(thisExe.GetName().Name + ".dao.config"); ConfigureHandler handler = new ConfigureHandler(ServiceConfig.Reset); // ibatis 读取配置 DomDaoManagerBuilder builder = new DomDaoManagerBuilder(); builder.Configure(stream); // builder.ConfigureAndWatch(handler); _instance = new ServiceConfig(); // TODO:默认为sqlMapDao指定的Context, 要提供对多个Context的支持. _instance._daoManager = IBatisNet.DataAccess.DaoManager.GetInstance("SqlMapDao"); // 转换到配置文件的数据库连接。 string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString; _instance._daoManager.LocalDataSource.ConnectionString = connectionString; } catch (Exception e) { ILog log = log4net.LogManager.GetLogger("TraceAppender"); log.Error(e); } } } } } catch (Exception ex) { Console.WriteLine(ex.Message); } return(_instance); }
static public ServiceConfig GetInstance() { if (_instance == null) { lock (_synRoot) { if (_instance == null) { ConfigureHandler handler = new ConfigureHandler(ServiceConfig.Reset); DomDaoManagerBuilder builder = new DomDaoManagerBuilder(); builder.ConfigureAndWatch("Dao.config", handler); builder.Configure(); _instance = new ServiceConfig(); // TODO:默认为sqlMapDao指定的Context, 要提供对多个Context的支持. _instance._daoManager = IBatisNet.DataAccess.DaoManager.GetInstance("SqlMapDao"); } } } return(_instance); }
static public ServiceConfig GetInstanceByFile() { if (_instance == null) { lock (_synRoot) { if (_instance == null) { //Define the Absoluate File path to Found the Dao File [f**k this shit] string filepath = @"E:\ADO.NEt Entity FrameWork Program\MyBatis_Demo\BatisDemonstarate_DUI\CustomerWeb_UI\Dao.Config"; if (File.Exists(filepath)) { DomDaoManagerBuilder getbuilder = new DomDaoManagerBuilder(); getbuilder.Configure(filepath); _instance = new ServiceConfig(); _instance._daoManager = IBatisNet.DataAccess.DaoManager.GetInstance("SqlMapDao"); } } } } return(_instance); }
/// <summary> /// 获得本地SqlMap /// </summary> /// <returns>获得与DAO相关的SqlMap</returns> protected ISqlMapper GetLocalSqlMap() { if (_sqlMapper == null) { //DomDaoManagerBuilder builder = new DomDaoManagerBuilder(); //builder.Configure(); IDaoManager daoManager = DaoManager.GetInstance(this); if (daoManager == null) { var builder = new DomDaoManagerBuilder(); builder.Configure(); daoManager = DaoManager.GetInstance(this); } var sqlMapDaoSession = (SqlMapDaoSession)daoManager.LocalDaoSession; _sqlMapper = sqlMapDaoSession.SqlMap; _sqlMapper.DataSource.ConnectionString = _sqlMapper.DataSource.ConnectionString; //SymmetricEncryption.DecryptString(_sqlMapper.DataSource.ConnectionString); } return(_sqlMapper); }
public void Init() { dal.Configure("dbconfig/dao.config"); }