void menuItem_integerContent_Click(object sender, EventArgs e) { TreeNode node = this.treeView_ber.SelectedNode; if (node == null) { MessageBox.Show(this, "尚未选定节点"); return; } BerNode bernode = (BerNode)node.Tag; MessageBox.Show(this, "'" + bernode.GetIntegerNodeData().ToString() + "'"); }
// 解码RPN结构中的Attribute + Term结构 static int DecodeAttributeAndTerm( Encoding term_encoding, BerNode pNode, out long lAttributeType, out long lAttributeValue, out string strTerm, out string strError) { lAttributeType = 0; lAttributeValue = 0; strTerm = ""; strError = ""; if (pNode == null) { strError = "node == null"; return(-1); } if (pNode.ChildrenCollection.Count < 2) //attriblist + term { strError = "bad RPN query"; return(-1); } BerNode pAttrib = pNode.ChildrenCollection[0]; // attriblist BerNode pTerm = pNode.ChildrenCollection[1]; // term if (44 != pAttrib.m_uTag) // Attributes { strError = "only support Attributes"; return(-1); } if (45 != pTerm.m_uTag) // Term { strError = "only support general Term"; return(-1); } // get attribute type and value if (pAttrib.ChildrenCollection.Count < 1) //attribelement { strError = "bad RPN query"; return(-1); } pAttrib = pAttrib.ChildrenCollection[0]; if (16 != pAttrib.m_uTag) //attribelement (SEQUENCE) { strError = "only support Attributes"; return(-1); } for (int i = 0; i < pAttrib.ChildrenCollection.Count; i++) { BerNode pTemp = pAttrib.ChildrenCollection[i]; switch (pTemp.m_uTag) { case 120: // attributeType lAttributeType = pTemp.GetIntegerNodeData(); break; case 121: // attributeValue lAttributeValue = pTemp.GetIntegerNodeData(); break; } } // get term strTerm = pTerm.GetCharNodeData(term_encoding); if (-1 == lAttributeType || -1 == lAttributeValue || String.IsNullOrEmpty(strTerm) == true) { strError = "bad RPN query"; return(-1); } return(0); }