public IEnumerable <BSMashStep> getMashProfile(string aRecepieName) { var ret = new List <BSMashStep>(); string errMsg = null; var xrs = XDoc.XPathSelectElements(XPATH_FOR_RECIPIES); var r = xrs.FirstOrDefault(x => x.Element(RECIPE_NAME_ELEMENT).Value.Equals(aRecepieName)); var xmss = r.XPathSelectElements(XPATH_FOR_MASHSTEPS); foreach (XElement xms in xmss) { float f; var m = new BSMashStep(); if (float.TryParse(xms.Element(MASH_STEP_TEMP_ELEMENT).Value, NumberStyles.AllowDecimalPoint, CultureInfo.CreateSpecificCulture("en-US"), out f)) { m.Temperature = (int)Math.Round(f); } else { errMsg = "Unable to parse one mash temperature in the mash profile"; } if (float.TryParse(xms.Element(MASH_STEP_TIME_ELEMENT).Value, NumberStyles.AllowDecimalPoint, CultureInfo.CreateSpecificCulture("en-US"), out f)) { m.TimeMinutes = (int)Math.Round(f); } else { errMsg = "Unable to parse one mash time in the mash profile"; } if (errMsg != null) { throw new ArgumentException(errMsg); } ret.Add(m); } return(ret); }
public IEnumerable<BSMashStep> getMashProfile(string aRecepieName) { var ret = new List<BSMashStep>(); string errMsg = null; var xrs = XDoc.XPathSelectElements(XPATH_FOR_RECIPIES); var r = xrs.FirstOrDefault(x => x.Element(RECIPE_NAME_ELEMENT).Value.Equals(aRecepieName)); var xmss = r.XPathSelectElements(XPATH_FOR_MASHSTEPS); foreach (XElement xms in xmss) { float f; var m = new BSMashStep(); if (float.TryParse(xms.Element(MASH_STEP_TEMP_ELEMENT).Value, NumberStyles.AllowDecimalPoint, CultureInfo.CreateSpecificCulture("en-US"), out f)) m.Temperature = (int)Math.Round(f); else errMsg = "Unable to parse one mash temperature in the mash profile"; if (float.TryParse(xms.Element(MASH_STEP_TIME_ELEMENT).Value, NumberStyles.AllowDecimalPoint, CultureInfo.CreateSpecificCulture("en-US"), out f)) m.TimeMinutes = (int)Math.Round(f); else errMsg = "Unable to parse one mash time in the mash profile"; if (errMsg != null) throw new ArgumentException(errMsg); ret.Add(m); } return ret; }