Example #1
0
        public void UpdateValue(RevisionTag revision, object value)
        {
            var node = root;

            foreach (int branch in revision)
            {
                if (node.Children == null)
                {
                    var newNode = new ValueTreeNode();
                    node.Children = new List <ValueTreeNode>(branch + 1);
                    node.Children.Insert(branch, newNode);
                    node = newNode;
                }
                else if (node.Children.Count <= branch)
                {
                    var newNode = new ValueTreeNode();
                    node.Children.Insert(branch, newNode);
                    node = newNode;
                }
                else
                {
                    var childNode = node.Children[branch];
                    if (childNode == null)
                    {
                        childNode = new ValueTreeNode();
                        node.Children.Insert(branch, childNode);
                    }
                    node = childNode;
                }
            }

            node.Value = value;
        }
Example #2
0
        public void AddValue(RevisionTag revision, object value)
        {
            var node = root;

            foreach (int branch in revision)
            {
                if (node.Children == null)
                {
                    var newNode = new ValueTreeNode();
                    node.Children = new List <ValueTreeNode>(branch + 1);
                    node.Children.Insert(branch, newNode);
                    node = newNode;
                }
                else if (node.Children.Count <= branch)
                {
                    var newNode = new ValueTreeNode();
                    node.Children.Insert(branch, newNode);
                    node = newNode;
                }
                else
                {
                    var childNode = node.Children[branch];
                    if (childNode == null)
                    {
                        childNode = new ValueTreeNode();
                        node.Children.Insert(branch, childNode);
                    }
                    node = childNode;
                }
            }

            if (node.Value != null)
            {
                throw new Exception("Property already Added");
            }

            node.Value = value;
        }