public static void Load(XmlNode valueDescNode, Dictionary <string, VdfValueDesc> valueDescTable) { VdfXncodeValueDesc xncodeValueDesc = VdfValueDesc.Load <VdfXncodeValueDesc>(valueDescNode, valueDescTable); if (xncodeValueDesc == null) { return; } valueDescTable.Add(xncodeValueDesc.Name, xncodeValueDesc); xncodeValueDesc.EntryTable = new Dictionary <int, string>(); //解析所有Entry var entryNodes = valueDescNode.SelectNodes(VdfTag.EntryElemName); foreach (XmlNode entryNode in entryNodes) { // 获取值 int value; if (!XmlUtils.TryGetIntAttrValue(entryNode, VdfTag.ValueAttrName, out value)) //首先尝试10进制解析 { // 失败时候使用十六进制解析 if (!XmlUtils.TryGetHexIntAttrValue(entryNode, VdfTag.ValueAttrName, out value)) { continue; } } // 获取描述 string desc; if (!XmlUtils.TryGetStringAttrValue(entryNode, VdfTag.DescriptionAttrName, out desc)) { continue; } try { xncodeValueDesc.EntryTable.Add(value, desc); } catch (Exception) { throw new VdfException(string.Format("Value Description [{0}] already exist " + "[Decimal:{1}, Hex:0x{1:X}] key", xncodeValueDesc.Name, value)); } } }
protected override void UpdateUI() { base.UpdateUI(); valDesc = Entity <VdfXncodeValueDesc>(); SuppressDeleteEvent = true; dataGridView.Rows.Clear(); SuppressDeleteEvent = false; if (valDesc != null) { textBoxName.Text = valDesc.Name; OldName = valDesc.Name; foreach (var ent in valDesc.EntryTable) { dataGridView.Rows.Add(new string[] { ent.Key.ToString(), ent.Value.ToString() }); } textBoxName.Enabled = (valDesc.Owners.Count == 0); } }