Beispiel #1
0
        private void WriteHeader()
        {
            Header header = new Header
            {
                Root         = this.Root,
                NextPosition = this.LastPosition,
                Order        = this.Order
            };

            using (var fs = new FileStream(this.Path, FileMode.OpenOrCreate))
            {
                fs.Seek(0, SeekOrigin.Begin);
                fs.Write(ByteGenerator.ConvertToBytes(header.ToFixedSizeString()), 0, header.FixedSizeText);
            }
        }
Beispiel #2
0
        /// <summary>
        /// To create a new file. Creates a Header and the Root node
        /// </summary>
        /// <param name="Order"></param>
        /// <param name="Path"></param>
        /// <param name="createFixedSizeText"></param>
        public Tree(int Order, string Path, ICreateFixedSizeText <T> createFixedSizeText)
        {
            this.createFixedSizeText = createFixedSizeText;
            this.Order = Order;
            this.Path  = Path;
            Node <T> root = CreateNode(Order);
            Header   e    = CreateHeader(Order);

            this.LastPosition = e.NextPosition;

            using (var fs = new FileStream(Path, FileMode.OpenOrCreate))
            {
                fs.Write(ByteGenerator.ConvertToBytes(e.ToFixedSizeString()), 0, e.FixedSizeText);
                fs.Write(ByteGenerator.ConvertToBytes(root.ToFixedSizeString()), 0, root.FixedSizeText());
            }
        }