/// <summary>
        /// Creates a new node that contains specified entries and children ids.
        /// </summary>
        public TreeNode <K, V> Create(IEnumerable <Tuple <K, V> > entries, IEnumerable <uint> childrenIds)
        {
            TreeNode <K, V> node = null;

            recordStorage.Create(id => {
                // Create a new node
                node = new TreeNode <K, V>(this, id, 0, entries, childrenIds);

                // Keep reference to all created nodes
                OnNodeInitialized(node);

                // Return the serialized value.
                return(serializer.Serialize(node));
            });

            if (node == null)
            {
                throw new Exception("Failed to create a new node.");
            }

            return(node);
        }
Beispiel #2
0
        //
        // Public Methods
        //

        public TreeNode <K, V> Create(IEnumerable <Tuple <K, V> > entries, IEnumerable <uint> childrenIds)
        {
            // Create new record
            TreeNode <K, V> node = null;

            recordStorage.Create(nodeId => {
                // Instantiate a new node
                node = new TreeNode <K, V> (this, nodeId, 0, entries, childrenIds);

                // Always keep reference to any node that we created
                OnNodeInitialized(node);

                // Return its deserialized value
                return(this.serializer.Serialize(node));
            });

            if (node == null)
            {
                throw new Exception("dataGenerator never called by nodeStorage");
            }

            return(node);
        }