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; }
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); }
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); }
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; }
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); }
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)); } } }