/// <summary> /// Use the name of this object as a value to insert into the specified 'newSimulation' /// </summary> private static void ApplyStringAsValue(Simulation newSimulation, string path, string name) { object originalValue = newSimulation.Get(path); object newValue; if (originalValue is DateTime) newValue = DateTime.Parse(name, CultureInfo.InvariantCulture); else if (originalValue is float) newValue = Convert.ToSingle(name, CultureInfo.InvariantCulture); else if (originalValue is double) newValue = Convert.ToDouble(name, CultureInfo.InvariantCulture); else if (originalValue is int) newValue = Convert.ToInt32(name, CultureInfo.InvariantCulture); else if (originalValue is string) newValue = Convert.ToString(name); else newValue = name; newSimulation.Set(path, newValue); }