public DataSourceInfoCollection CombineOnSetDataSources(DataSourceInfoCollection newDataSources) { DataSourceInfoCollection dataSourceInfoCollection = new DataSourceInfoCollection(); foreach (DataSourceInfo newDataSource in newDataSources) { DataSourceInfo byOriginalName = this.GetByOriginalName(newDataSource.OriginalName); if (byOriginalName == null) { throw new DataSourceNotFoundException(newDataSource.OriginalName); } newDataSource.ID = byOriginalName.ID; newDataSource.SetOriginalConnectionString(byOriginalName.OriginalConnectionStringEncrypted); newDataSource.SetOriginalConnectStringExpressionBased(byOriginalName.OriginalConnectStringExpressionBased); dataSourceInfoCollection.Add(newDataSource); } foreach (DataSourceInfo item in this) { DataSourceInfo byOriginalName2 = newDataSources.GetByOriginalName(item.OriginalName); if (byOriginalName2 == null) { dataSourceInfoCollection.Add(item); } } return(dataSourceInfoCollection); }
private DataSourceInfoCollection CombineOnSetDefinition(DataSourceInfoCollection newDataSources, bool keepOriginalDataSourceId, bool overrideOriginalConnectString) { DataSourceInfoCollection dataSourceInfoCollection = new DataSourceInfoCollection(); foreach (DataSourceInfo newDataSource in newDataSources) { DataSourceInfo byOriginalName = this.GetByOriginalName(newDataSource.OriginalName); if (byOriginalName == null) { dataSourceInfoCollection.Add(newDataSource); } else { if (!keepOriginalDataSourceId) { byOriginalName.ID = newDataSource.ID; } if (overrideOriginalConnectString) { byOriginalName.SetOriginalConnectionString(newDataSource.OriginalConnectionStringEncrypted); byOriginalName.SetOriginalConnectStringExpressionBased(newDataSource.OriginalConnectStringExpressionBased); } dataSourceInfoCollection.Add(byOriginalName); } } return(dataSourceInfoCollection); }