/// <summary> /// Releases unmanaged and - optionally - managed resources. /// </summary> /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param> protected virtual void Dispose(bool disposing) { if (!disposing) { return; } if (_loggingContext != null) { _loggingContext.Dispose(); } if (_webshopContext != null) { _webshopContext.Dispose(); } }
static void CheckIfConnectionStringExists() { if (String.IsNullOrEmpty(ConnectionString)) { throw new Exception("Connection string is not set. Use LogManager.ConnectionString to set a new connection string."); } else { try { var context = new LoggingContext(); context.Dispose(); } catch (Exception exception) { throw new Exception("Invalid connection string or name. Try re-setting LogManager.ConnectionString."); } } Database.SetInitializer(new GenericInitializer <LoggingContext>()); }