/// <summary> /// Save node data into Stream. /// </summary> /// <param name="xdata">Stream.</param> /// <returns>true:Succeed; false:failed.</returns> public bool SaveData(Stream xdata) { bool retval = true; long nodeCount = ChildNodeCount; xdata.WriteByte(Tag); _utilities.DerLengthEncode(xdata, (ulong)_dataLength); if (Tag == Asn1Type.BitString) { xdata.WriteByte(_unusedBits); } if (nodeCount == 0) { if (_data != null) { xdata.Write(_data, 0, _data.Length); } } else { int i; for (i = 0; i < nodeCount; i++) { Asn1Node tempNode = GetChildNode(i); retval = tempNode.SaveData(xdata); } } return(retval); }
private Asn1Node(Asn1Node parentNode, long dataOffset) { Init(); Deepness = parentNode.Deepness + 1; ParentNode = parentNode; _dataOffset = dataOffset; }
/// <summary> /// Retrieve child node by index. /// </summary> /// <param name="index">0 based index.</param> /// <returns>0 based index.</returns> public Asn1Node GetChildNode(int index) { Asn1Node retval = null; if (index < ChildNodeCount) { retval = (Asn1Node)_childNodeList[index]; } return(retval); }
/// <summary> /// Clear data and children list. /// </summary> public void ClearAll() { _data = null; foreach (object t in _childNodeList) { Asn1Node tempNode = (Asn1Node)t; tempNode.ClearAll(); } _childNodeList.Clear(); RecalculateTreePar(); }
/// <summary> /// Add child node at the end of children list. /// </summary> /// <param name="xdata">the node that will be add in.</param> public void AddChild(Asn1Node xdata) { _childNodeList.Add(xdata); RecalculateTreePar(); }