public void CopyTo(MeasurableParameterMapping measurableParameterMapping) { measurableParameterMapping.Id = Id; measurableParameterMapping.Optimal = Optimal; measurableParameterMapping.Min = Min; measurableParameterMapping.Max = Max; measurableParameterMapping.Type = Type; }
public MeasurableParameter RestoreMeasurableParameter(MeasurableParameterMapping measurableParameterMapping) { try { ParameterEnum parameter; bool parsed = Enum.TryParse(measurableParameterMapping.Type, out parameter); if (parsed) { switch (parameter) { case ParameterEnum.Nutrient: return new Nutrient(measurableParameterMapping.Id, measurableParameterMapping.Optimal, measurableParameterMapping.Min, measurableParameterMapping.Max); case ParameterEnum.SoilPh: return new SoilPh(measurableParameterMapping.Id, measurableParameterMapping.Optimal, measurableParameterMapping.Min, measurableParameterMapping.Max); case ParameterEnum.Humidity: return new Humidity(measurableParameterMapping.Id, measurableParameterMapping.Optimal, measurableParameterMapping.Min, measurableParameterMapping.Max); case ParameterEnum.Temperature: return new Temperature(measurableParameterMapping.Id, measurableParameterMapping.Optimal, measurableParameterMapping.Min, measurableParameterMapping.Max); } } //if custom sensor return new CustomParameter(measurableParameterMapping.Id, measurableParameterMapping.Optimal, measurableParameterMapping.Min, measurableParameterMapping.Max, measurableParameterMapping.Type); } catch (Exception e) { MessageBox.Show(e.StackTrace, $"MeasurableParameter Id: {measurableParameterMapping.Id}"); return null; } }