Beispiel #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;
        }
Beispiel #2
0
        public void RemoveValue(RevisionTag revision)
        {
            var node          = root;
            int branch2delete = -1;
            var parent        = root;

            foreach (int branch in revision)
            {
                branch2delete = branch;
                if (node.Children == null || node.Children.Count <= branch)
                {
                    return;
                }

                var childNode = node.Children[branch];
                if (childNode == null)
                {
                    return;
                }

                node = childNode;
            }

            parent.Children.RemoveAt(branch2delete);
        }
Beispiel #3
0
        public object GetValue(RevisionTag revision)
        {
            var    node  = root;
            object value = root.Value;

            foreach (int branch in revision)
            {
                if (node.Children == null)
                {
                    return(value);
                }
                if (node.Children.Count <= branch)
                {
                    return(value);
                }
                var values = node.Children[branch];
                if (values == null)
                {
                    return(value);
                }
                node  = node.Children[branch];
                value = node.Value;
            }

            return(value);
        }
Beispiel #4
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;
        }
Beispiel #5
0
        internal ValueTreeNode GetNode(RevisionTag revision)
        {
            var node = root;

            foreach (int branch in revision)
            {
                if (node.Children == null)
                {
                    return(null);
                }
                if (node.Children.Count <= branch)
                {
                    return(null);
                }
                var values = node.Children[branch];
                if (values == null)
                {
                    return(null);
                }
                node = node.Children[branch];
            }

            return(node);
        }
Beispiel #6
0
        public IEnumerable <Tuple <int, ModInfo.Revision> > FindModRevisionsByTag(string modId, RevisionTag tag)
        {
            var revList = LoadedMods[modId].Revisions;

            for (int index = revList.Count - 1; index >= 0; index--)
            {
                var revision = revList[index];

                if (revision.Tag == tag)
                {
                    yield return(new Tuple <int, ModInfo.Revision>(index, revision));
                }
            }
        }