private void ProcessParameters() { try { if (SelectedProvider == null) { throw new Exception("No provider selected"); } var meta = SelectedProvider.GetMetaFields(); foreach (Control c in optionsGrid.Children) { if (c.Tag != null) { string id = c.Tag.ToString(); string value = null; if (c is TextBox) { value = ((TextBox)c).Text; } else if (c is ComboBox) { value = ((ComboBox)c).Text; } else if (c is CheckBox) { value = ((CheckBox)c).IsChecked.ToString(); } else { //Error } var item = meta.FirstOrDefault(x => x.ID == id); if (item != null) //TODO: Disabled hack { item.SetValue(value); } } } var newSource = selectedProvider.CreateNewSource( selectedProvider.HasUniqueName ? Name : null //Probably just use name , null, meta); if (selectedProvider.HasUrlField) { newSource.SetMetaData(new MetaDataObject(SourceViewModel.URL, SourceViewModel.URL, url)); } newSource.SetMetaData(new MetaDataObject(SourceViewModel.UPDATES_COLOR, SourceViewModel.UPDATES_COLOR, SourceViewModel.SerializeColor(selectedColor))); newSource.SetMetaData(new MetaDataObject(SourceViewModel.DISABLED, SourceViewModel.DISABLED, disabled)); if (originalSource != null) { newSource.SetID(originalSource.Data.ID.Value); datastore.UpdateSource(newSource); originalSource.SetSource(newSource); } else { datastore.AddSource(newSource); originalSource = new SourceViewModel(newSource); } window.Close(); } catch (Exception ex) { MessageBoxFactory.ShowError(ex); } }