コード例 #1
0
        /// <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);
        }
コード例 #2
0
 private Asn1Node(Asn1Node parentNode, long dataOffset)
 {
     Init();
     Deepness    = parentNode.Deepness + 1;
     ParentNode  = parentNode;
     _dataOffset = dataOffset;
 }
コード例 #3
0
        /// <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);
        }
コード例 #4
0
 /// <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();
 }
コード例 #5
0
 /// <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();
 }