public void LoadUnitConfigFile(string sFilePath) { try { XmlDocument doc = new XmlDocument(); doc.Load(sFilePath); XmlElement root = doc.DocumentElement; XmlNodeList cateNodes = root.SelectNodes("Category"); List <IBxUnitCategory> cates = new List <IBxUnitCategory>(cateNodes.Count); BxSubSetUnitCategory cate; IBxUnitCategory baseCate; string id, name; foreach (XmlElement one in cateNodes) { id = one.GetAttribute("id"); name = one.GetAttribute("help"); if (string.IsNullOrWhiteSpace(name)) { name = id; } baseCate = _baseUnitsCenter.Parse(id); cate = new BxSubSetUnitCategory(baseCate, name); cate.LoadUnitConfigNode(one); cates.Add(cate); } cates.Sort((x, y) => string.Compare(x.Name, y.Name)); _cates = cates; } catch (System.Exception) { } }
public static IBxUnit EMParse(this IBxUnitsCenter center, string unitCate, string unit) { IBxUnitCategory cate = center.Parse(unitCate); if (cate == null) { return(null); } return(cate.Parse(unit)); }
static protected IBxUnit S_ParseUnit(string unitCate, string unit) { IBxUnitsCenter units = BLSystemInfo.Instance.Units; IBxUnitCategory cate = units.Parse(unitCate); if (cate != null) { return(cate.Parse(unit)); } return(null); }