internal static void Initialize(string configFile) { DatabaseConnectionSettingsCollection connections = null; if (File.Exists(configFile)) { try { using (FileStream fs = File.OpenRead(configFile)) { XmlSerializer serializer = new XmlSerializer(typeof(DatabaseConnectionSettingsCollection)); connections = (DatabaseConnectionSettingsCollection)serializer.Deserialize(fs); } } catch { LoggingService.LogError(AddinCatalog.GetString("Unable to load stored SQL connection information.")); File.Delete(configFile); } } contexts = new DatabaseConnectionContextCollection(); if (connections != null) { StringBuilder sb = new StringBuilder(); foreach (DatabaseConnectionSettings settings in connections) { IDbFactory fac = DbFactoryService.GetDbFactory(settings); if (fac == null) { sb.Append("Error: unable to load database provider '"); sb.Append(settings.ProviderIdentifier); sb.Append("' for connection '"); sb.Append(settings.Name); sb.Append("'"); sb.Append(Environment.NewLine); continue; } contexts.Add(new DatabaseConnectionContext(settings)); } if (sb.Length > 0) { Exception ex = new Exception(sb.ToString()); QueryService.RaiseException(ex); } } }