internal static InterfaceConfigurationElement AddNew(string providerName, DataTypeDescriptor dataTypeDescriptor) { lock (_syncRoot) { var configuration = new SqlDataProviderConfiguration(providerName); if (configuration.Section.Interfaces.ContainsInterfaceType(dataTypeDescriptor.DataTypeId)) { Log.LogWarning(LogTitle, "Configuration file '{0}' already contains an interface with data type ID '{1}', type name '{2}'. " + "Possibly there are multiple AppDomain-s running.", configuration.ConfigurationFilePath, dataTypeDescriptor.DataTypeId, dataTypeDescriptor); return configuration.Section.Interfaces.Get(dataTypeDescriptor); } InterfaceConfigurationElement interfaceConfig = BuildInterfaceConfigurationElement(dataTypeDescriptor); configuration.Section.Interfaces.Add(interfaceConfig); configuration.Save(); return interfaceConfig; } }
internal static InterfaceConfigurationElement AddNew(string providerName, DataTypeDescriptor dataTypeDescriptor) { lock (_syncRoot) { var configuration = new SqlDataProviderConfiguration(providerName); if (configuration.Section.Interfaces.ContainsInterfaceType(dataTypeDescriptor.DataTypeId)) { Log.LogWarning(LogTitle, "Configuration file '{0}' already contains an interface with data type ID '{1}', type name '{2}'. " + "Possibly there are multiple AppDomain-s running.", configuration.ConfigurationFilePath, dataTypeDescriptor.DataTypeId, dataTypeDescriptor); return(configuration.Section.Interfaces.Get(dataTypeDescriptor)); } InterfaceConfigurationElement interfaceConfig = BuildInterfaceConfigurationElement(dataTypeDescriptor); configuration.Section.Interfaces.Add(interfaceConfig); configuration.Save(); return(interfaceConfig); } }
internal static void Remove(string providerName, DataTypeDescriptor dataTypeDescriptor) { lock (_syncRoot) { var configuration = new SqlDataProviderConfiguration(providerName); if (configuration.Section.Interfaces.ContainsInterfaceType(dataTypeDescriptor)) { configuration.Section.Interfaces.Remove(dataTypeDescriptor); configuration.Save(); } } }
internal static InterfaceConfigurationElement Change(string providerName, DataTypeChangeDescriptor changeDescriptor, bool localeChanges) { lock (_syncRoot) { var originalType = changeDescriptor.OriginalType; var alteredType = changeDescriptor.AlteredType; bool typeNameChanged = originalType.Namespace != alteredType.Namespace || originalType.Name != alteredType.Name; if (!localeChanges && !changeDescriptor.AddedDataScopes.Any() && !changeDescriptor.DeletedDataScopes.Any() && !changeDescriptor.AddedKeyFields.Any() && !changeDescriptor.DeletedKeyFields.Any() && !changeDescriptor.KeyFieldsOrderChanged && !typeNameChanged) { // No changes to the config is needed, lets not touch the file. return(null); } var configuration = new SqlDataProviderConfiguration(providerName); Guid dataTypeId = originalType.DataTypeId; var existingElement = configuration.Section.Interfaces.Get(originalType); Verify.IsNotNull(existingElement, "Configuration does not contain the original interface with id '{0}'", dataTypeId); configuration.Section.Interfaces.Remove(originalType); InterfaceConfigurationElement newInterfaceConfig = BuildInterfaceConfigurationElement(alteredType, existingElement, typeNameChanged); configuration.Section.Interfaces.Add(newInterfaceConfig); configuration.Save(); return(newInterfaceConfig); } }
internal static InterfaceConfigurationElement Change(string providerName, DataTypeChangeDescriptor changeDescriptor, bool localeChanges) { lock (_syncRoot) { var originalType = changeDescriptor.OriginalType; var alteredType = changeDescriptor.AlteredType; bool typeNameChanged = originalType.Namespace != alteredType.Namespace || originalType.Name != alteredType.Name; if (!localeChanges && !changeDescriptor.AddedDataScopes.Any() && !changeDescriptor.DeletedDataScopes.Any() && !changeDescriptor.AddedKeyFields.Any() && !changeDescriptor.DeletedKeyFields.Any() && !changeDescriptor.KeyFieldsOrderChanged && !typeNameChanged) { // No changes to the config is needed, lets not touch the file. return null; } var configuration = new SqlDataProviderConfiguration(providerName); Guid dataTypeId = originalType.DataTypeId; var existingElement = configuration.Section.Interfaces.Get(originalType); Verify.IsNotNull(existingElement, "Configuration does not contain the original interface with id '{0}'", dataTypeId); configuration.Section.Interfaces.Remove(originalType); InterfaceConfigurationElement newInterfaceConfig = BuildInterfaceConfigurationElement(alteredType, existingElement, typeNameChanged); configuration.Section.Interfaces.Add(newInterfaceConfig); configuration.Save(); return newInterfaceConfig; } }