public void Set1DimensionalParameter <D1, T>(string componentName, string fieldName, ParameterValues parameters, string parameterName) where T : struct where D1 : IDimension { var fieldKey = new Tuple <string, string>(componentName.ToLowerInvariant(), fieldName.ToLowerInvariant()); if (!_dimensionalVariables.ContainsKey(fieldKey)) { throw new InvalidOperationException(); } var p = (ParameterValue1Dimensional <T>)parameters[parameterName.ToLowerInvariant()]; if (typeof(D1) == typeof(Timestep)) { var value = new FieldParameter1DimensionalTime <T>(this, p); _dimensionalVariables[fieldKey] = value; } else if (typeof(D1).BaseType == typeof(Enum)) { var value = new FieldParameter1Dimensional <D1, T>(this, p); _dimensionalVariables[fieldKey] = value; } else { throw new ArgumentException("Unknown dimension type"); } }
public void LoadOneDimensionalVariableFromParameters <D1, T>(string componentName, string fieldName, ParameterValues parameters) where T : struct where D1 : IDimension { var p = (ParameterValue1Dimensional <T>)parameters[fieldName.ToLowerInvariant()]; if (typeof(D1) == typeof(Timestep)) { var value = new FieldParameter1DimensionalTime <T>(this, p); Add1DimensionalParameter <Timestep, T>(componentName.ToLowerInvariant(), fieldName.ToLowerInvariant(), value); } else if (typeof(IDimension).IsAssignableFrom(typeof(D1))) { var value = new FieldParameter1Dimensional <D1, T>(this, p); Add1DimensionalParameter <D1, T>(componentName.ToLowerInvariant(), fieldName.ToLowerInvariant(), value); } else { throw new ArgumentException("Unknown dimension type"); } }