protected TableBasedGeneratorBase(string keyName, Sooda.Schema.DataSourceInfo dataSourceInfo) { this.keyName = keyName; this.dataSourceInfo = dataSourceInfo; table_name = SoodaConfig.GetString(dataSourceInfo.Name + ".keygentable.name", "KeyGen"); key_name_column = SoodaConfig.GetString(dataSourceInfo.Name + ".keygentable.keycolumn", "key_name"); key_value_column = SoodaConfig.GetString(dataSourceInfo.Name + ".keygentable.valuecolumn", "key_value"); poolSize = Convert.ToInt32(SoodaConfig.GetString(dataSourceInfo.Name + ".keygentable.pool_size", "10")); }
public override void Open() { if (ConnectionString == null) { throw new SoodaDatabaseException("connectionString parameter not defined for datasource: " + Name); } if (ConnectionType == null) { throw new SoodaDatabaseException("connectionType parameter not defined for datasource: " + Name); } string stries = SoodaConfig.GetString("sooda.connectionopenretries", "2"); int tries; try { tries = Convert.ToInt32(stries); } catch { tries = 2; } int maxtries = tries; OwnConnection = true; while (tries > 0) { try { Connection = (IDbConnection)Activator.CreateInstance(ConnectionType, new object[] { ConnectionString }); Connection.Open(); if (!DisableTransactions) { BeginTransaction(); if (this.SqlBuilder is OracleBuilder && SoodaConfig.GetString("sooda.oracleClientAutoCommitBugWorkaround", "false") == "true") { // http://social.msdn.microsoft.com/forums/en-US/adodotnetdataproviders/thread/d4834ce2-482f-40ec-ad90-c3f9c9c4d4b1/ // http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=351746 Connection.GetType().GetProperty("TransactionState", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).SetValue(Connection, 1, null); } } tries = 0; } catch (Exception e) { tries--; logger.Warn("Exception on Open#{0}: {1}", maxtries - tries, e); bool eject = tries == 0 || SqlBuilder.HandleFatalException(Connection, e); Close(); //release db connection if (eject) { throw e; } } } }
static SoodaCache() { string cachingPolicy = SoodaConfig.GetString("sooda.cachingPolicy", "none"); string cacheType = SoodaConfig.GetString("sooda.cache.type", "inprocess"); switch (cachingPolicy) { case "none": _defaultCachingPolicy = new SoodaNoCachingPolicy(); break; case "all": _defaultCachingPolicy = new SoodaCacheAllPolicy(); break; case "small": _defaultCachingPolicy = new SoodaCacheSmallPolicy(); break; case "smallmedium": _defaultCachingPolicy = new SoodaCacheSmallAndMediumPolicy(); break; default: _defaultCachingPolicy = Activator.CreateInstance(Type.GetType(cachingPolicy, true)) as ISoodaCachingPolicy; break; } switch (cacheType) { case "none": _defaultCache = new SoodaNoCache(); break; case "inprocess": _defaultCache = new SoodaInProcessCache(); break; default: _defaultCache = Activator.CreateInstance(Type.GetType(cacheType, true)) as ISoodaCache; break; } if (_defaultCachingPolicy == null) { _defaultCachingPolicy = new SoodaNoCachingPolicy(); } if (_defaultCache == null) { _defaultCache = new SoodaInProcessCache(); } ISoodaCachingPolicyFixedTimeout sft = _defaultCachingPolicy as ISoodaCachingPolicyFixedTimeout; if (sft != null) { sft.SlidingExpiration = Convert.ToBoolean(SoodaConfig.GetString("sooda.cachingPolicy.slidingExpiration", "true"), CultureInfo.InvariantCulture); sft.ExpirationTimeout = TimeSpan.FromSeconds( Convert.ToInt32(SoodaConfig.GetString("sooda.cachingPolicy.expirationTimeout", "120"), CultureInfo.InvariantCulture)); } logger.Debug("Default cache: {0} Policy: {1}", _defaultCache.GetType().Name, _defaultCachingPolicy.GetType().Name); }
static LogManager() { // set up null implementation first so that any logging statements // from SoodaConfig will not result in NullReferenceException _implementation = new NullLoggingImplementation(); try { string loggingImplementationName = SoodaConfig.GetString("sooda.logging", "null"); string typeName; switch (loggingImplementationName) { case "console": _implementation = new ConsoleLoggingImplementation(); break; case "null": _implementation = new NullLoggingImplementation(); break; case "nlog": typeName = "Sooda.Logging.NLog.LoggingImplementation, Sooda.Logging.NLog"; _implementation = Activator.CreateInstance(Type.GetType(typeName)) as ILoggingImplementation; break; case "log4net": typeName = "Sooda.Logging.log4net.LoggingImplementation, Sooda.Logging.log4net"; _implementation = Activator.CreateInstance(Type.GetType(typeName)) as ILoggingImplementation; break; default: _implementation = Activator.CreateInstance(Type.GetType(loggingImplementationName)) as ILoggingImplementation; break; } } catch (Exception) { _implementation = new NullLoggingImplementation(); } finally { if (_implementation == null) { _implementation = new NullLoggingImplementation(); } } }