public void Setup() { if (String.IsNullOrEmpty(ConfigPath)) { ConfigPath = Consts.DEFAULT_SMARTSQL_CONFIG_PATH; } if (String.IsNullOrEmpty(Alias)) { Alias = ConfigPath; } if (LoggerFactory == null) { LoggerFactory = NoneLoggerFactory.Instance; } if (ConfigLoader == null) { ConfigLoader = new LocalFileConfigLoader(ConfigPath, LoggerFactory); } var sqlMapConfig = ConfigLoader.Load(); SmartSqlContext = new SmartSqlContext(LoggerFactory.CreateLogger <SmartSqlContext>(), sqlMapConfig); if (DbSessionStore == null) { DbSessionStore = new DbConnectionSessionStore(LoggerFactory, SmartSqlContext.DbProvider.Factory); } if (DataSourceFilter == null) { DataSourceFilter = new DataSourceFilter(LoggerFactory.CreateLogger <DataSourceFilter>(), DbSessionStore, SmartSqlContext); } if (SqlBuilder == null) { SqlBuilder = new SqlBuilder(LoggerFactory.CreateLogger <SqlBuilder>()); } if (PreparedCommand == null) { PreparedCommand = new PreparedCommand(LoggerFactory.CreateLogger <PreparedCommand>(), SmartSqlContext); } if (CommandExecuter == null) { CommandExecuter = new CommandExecuter(LoggerFactory.CreateLogger <CommandExecuter>(), PreparedCommand); } if (DataReaderDeserializerFactory == null) { DataReaderDeserializerFactory = new EmitDataReaderDeserializerFactory(); } if (CacheManager == null) { if (SmartSqlContext.IsCacheEnabled) { CacheManager = new CacheManager(LoggerFactory.CreateLogger <CacheManager>(), SmartSqlContext, DbSessionStore); } else { CacheManager = new NoneCacheManager(); } } ConfigLoader.OnChanged += ConfigLoader_OnChanged; }
private static IProcessEngineBuilder AddSmartSqlMapper(this IProcessEngineBuilder builder) { builder.Services.AddSingleton <ISmartSqlMapper>(sp => { var codebase = AppDomain.CurrentDomain.BaseDirectory; IDataSource dataSource = sp.GetService <IDataSource>(); var dbSessionStore = new DbConnectionSessionStore(sp.GetService <ILoggerFactory>(), dataSource.DbProviderFactory); SmartSqlOptions options = new SmartSqlOptions { ConfigPath = Path.Combine(codebase, DEFAULT_MYBATIS_MAPPING_FILE), DbSessionStore = dbSessionStore }; SmartSqlMapper ssm = new SmartSqlMapper(options); options.SmartSqlContext.Settings.IsWatchConfigFile = true; options.SmartSqlContext.Database.WriteDataSource.ConnectionString = dataSource.ConnectionString; foreach (var ds in options.SmartSqlContext.Database.ReadDataSources) { ds.ConnectionString = dataSource.ConnectionString; } return(ssm); }); return(builder); }
public BaraMapper(String baraMapConfigFilePath, IConfigLoader configLoader) { ConfigLoader = configLoader; ConfigLoader.Load(baraMapConfigFilePath, this); DbProviderFactory = BaraMapConfig.DataBase.DbProvider.DbProviderFactory; SessionStore = new DbConnectionSessionStore(this.GetHashCode().ToString()); SqlBuilder = new SqlBuilder(this); DataSourceManager = new DataSourceManager(this); CacheManager = new CacheManager(this); SqlExecutor = new SqlExecutor(SqlBuilder, this); }
public SmartSqlMapper(String sqlMapConfigFilePath, IConfigLoader configLoader) { ConfigLoader = configLoader; ConfigLoader.Load(sqlMapConfigFilePath, this); DbProviderFactory = SqlMapConfig.Database.DbProvider.DbProviderFactory; SessionStore = new DbConnectionSessionStore(this.GetHashCode().ToString()); SqlBuilder = new SqlBuilder(this); DataSourceManager = new DataSourceManager(this); CacheManager = new CacheManager(this); _sqlRuner = new SqlRuner(SqlBuilder, this); }
public BaraMapper(ILoggerFactory loggerFactory, String baraMapConfigFilePath, IConfigLoader configLoader) { _loggerFactory = loggerFactory; _logger = _loggerFactory.CreateLogger <BaraMapper>(); ConfigLoader = configLoader; ConfigLoader.Load(baraMapConfigFilePath, this); DbProviderFactory = BaraMapConfig.DataBase.DbProvider.DbProviderFactory; SessionStore = new DbConnectionSessionStore(loggerFactory, this.GetHashCode().ToString()); SqlBuilder = new SqlBuilder(loggerFactory, this); DataSourceManager = new DataSourceManager(loggerFactory, this); CacheManager = new CacheManager(loggerFactory, this); SqlExecutor = new SqlExecutor(loggerFactory, SqlBuilder, this); }
public SmartSqlMapper(ILoggerFactory loggerFactory, String sqlMapConfigFilePath, IConfigLoader configLoader) { _loggerFactory = loggerFactory; _logger = loggerFactory.CreateLogger <SmartSqlMapper>(); ConfigLoader = configLoader; SqlMapConfig = ConfigLoader.Load(); DbProviderFactory = SqlMapConfig.Database.DbProvider.DbProviderFactory; SessionStore = new DbConnectionSessionStore(loggerFactory, this.GetHashCode().ToString()); SqlBuilder = new SqlBuilder(loggerFactory, this); DataSourceManager = new DataSourceManager(loggerFactory, this); CacheManager = new CacheManager(loggerFactory, this); _sqlRuner = new SqlRuner(loggerFactory, SqlBuilder, this); ConfigLoader.OnChanged = SqlConfigOnChanged; SqlMapConfig.SetLogger(_loggerFactory.CreateLogger <SmartSqlMapConfig>()); }
public SmartSqlMapper( ILoggerFactory loggerFactory, String sqlMapConfigFilePath = "SmartSqlMapConfig.xml" ) { _loggerFactory = loggerFactory; _logger = loggerFactory.CreateLogger <SmartSqlMapper>(); ConfigLoader = new LocalFileConfigLoader(loggerFactory); ConfigLoader.Load(sqlMapConfigFilePath, this); DbProviderFactory = SqlMapConfig.Database.DbProvider.DbProviderFactory; SessionStore = new DbConnectionSessionStore(loggerFactory, this.GetHashCode().ToString()); SqlBuilder = new SqlBuilder(loggerFactory, this); DataSourceManager = new DataSourceManager(loggerFactory, this); CacheManager = new CacheManager(loggerFactory, this); _sqlRuner = new SqlRuner(loggerFactory, SqlBuilder, this); }
public void CreateInstance() { DbConnectionSessionStore sesstionStore = new DbConnectionSessionStore(NullLoggerFactory.Instance, "dbStore"); Assert.NotNull(sesstionStore); }
public void CreateInstance() { DbConnectionSessionStore sesstionStore = new DbConnectionSessionStore("dbStore"); Assert.NotNull(sesstionStore); }