Ejemplo n.º 1
0
        internal Dictionary <string, object> Flatten()
        {
            Dictionary <string, object> toUpdate = new Dictionary <string, object>();

            if (IsLeaf)
            {
                toUpdate.Add("value", ((ChangeSetLeaf)this).Value);
            }
            else
            {
                ChangesetBranch branch = (ChangesetBranch)this;
                foreach (var item in branch.childs.Keys)
                {
                    var key   = "/" + item;
                    var child = branch[item];
                    if (child.IsLeaf)
                    {
                        toUpdate[key] = ((ChangeSetLeaf)child).Value;
                    }
                    else
                    {
                        foreach (var childItem in child.Flatten())
                        {
                            toUpdate[key + childItem.Key] = childItem.Value;
                        }
                    }
                }
            }

            return(toUpdate);
        }
Ejemplo n.º 2
0
        internal static ChangeSet FromFlatDictionary(Dictionary <string, object> data)
        {
            ChangesetBranch branch = new ChangesetBranch(new Dictionary <string, ChangeSet>());

            foreach (var item in data)
            {
                branch.addPathedValue(item.Key, item.Value);
            }
            return(branch);
        }
Ejemplo n.º 3
0
        internal static ChangeSet FromFlatJToken(JToken token)
        {
            ChangesetBranch branch = new ChangesetBranch(new Dictionary <string, ChangeSet>());

            foreach (var item in token.Children <JProperty>())
            {
                branch.addPathedValue(item.Name, ((JValue)item.Value).Value);
            }
            return(branch);
        }