/// <summary> /// Get the edited configuration. /// </summary> /// <returns>The edited configuration.</returns> public ClusterConfiguration GetConfiguration() { var type = (ClusterConfiguration.ClusterType)Enum.Parse(typeof(ClusterConfiguration.ClusterType), this.comboBox_clusterType.Text); ClusterConfigurationSerialization ser = new ClusterConfigurationSerialization() { Name = this.textBox_name.Text, Type = type, Properties = new List<PropertySetting>() }; foreach (var ctrl in this.propEditor) { ser.Properties.Add(new PropertySetting(ctrl.Key, ctrl.Value.Text)); } ClusterConfiguration result = ser.Create(); string error = result.Initialize(); if (error == null) return result; else { MessageBox.Show("Error while initializing cluster configuration: " + error); return null; } }
/// <summary> /// Create serialization data structure for this configuration. /// </summary> /// <returns>The corresponding serialization.</returns> public ClusterConfigurationSerialization ExtractData() { ClusterConfigurationSerialization result = new ClusterConfigurationSerialization { Type = this.TypeOfCluster, Name = this.Name, Properties = new List<PropertySetting>() }; foreach (var prop in this.GetPropertiesToEdit()) { var property = this.GetType().GetProperty(prop); var value = property.GetValue(this); PropertySetting setting = new PropertySetting(prop, value != null ? value.ToString() : null); result.Properties.Add(setting); } return result; }