Variable GetConstant(XElement xElement, ConstantProperties prop) { if (xElement == null) { throw new ArgumentException("xElement was null"); } var uom = ParseUOM((string)xElement.Attribute("units")); var constant = new Variable(prop.ToString(), (double)xElement.Attribute("value"), uom); return(constant); }
/// <summary> /// Retrieve the constant for a given constant ID /// </summary> /// <param name="id"></param> /// <returns></returns> public Variable GetConstant(ConstantProperties id) { var constant = Constants.FirstOrDefault(c => c.Name == id.ToString()); if (constant != null) { return(constant); } else { throw new ArgumentException("Constant ID not found"); } }