private ParseTree Extend(ParseTree other, bool justFields) { if (other == No) throw new NotSupportedException("Should not extend from ParseTree.No"); if (this == No) throw new NotSupportedException("ParseTree.No is read only"); ParseTree tree = this; if (!justFields) { single = false; if ((other.nodes != null) && (other.nodes.Count > 0)) { if (tree == ParseTree.Yes) tree = new ParseTree(); if (tree.nodes == null) tree.nodes = new List<object>(); tree.nodes.AddRange(other.nodes); } } if ((other.fields != null) && (other.fields.Count > 0)) { if (tree == ParseTree.Yes) tree = new ParseTree(); if (tree.fields == null) tree.fields = new Dictionary<string, object>(); foreach (KeyValuePair<string, object> field in other.fields) tree.fields[field.Key] = field.Value; } return tree; }
public ParseTree ExtendFields(ParseTree other) { return Extend(other, true); }
public ParseTree Extend(ParseTree other) { return Extend(other, false); }