public IDictionary <string, object> FlattenDictionary() { Dictionary <string, object> toUpdate = new Dictionary <string, object>(); if (IsLeaf) { toUpdate.Add("value", ((DataLeaf)this).Value); } else { DataBranch branch = (DataBranch)this; foreach (var item in branch.Keys) { var child = branch[item]; if (child.IsLeaf) { toUpdate[item] = ((DataLeaf)child).Value; } else { foreach (var childItem in child.FlattenDictionary()) { toUpdate[item + "/" + childItem.Key] = childItem.Value; } } } } return(toUpdate); }
public override DataBranch AsBranch() { var myPath = Path; var result = new DataBranch(new Dictionary <string, DataNode>() { { "value", this } }); result.Path = myPath; Path = myPath; return(result); }