コード例 #1
0
        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);
        }
コード例 #2
0
        public override DataBranch AsBranch()
        {
            var myPath = Path;
            var result = new DataBranch(new Dictionary <string, DataNode>()
            {
                { "value", this }
            });

            result.Path = myPath;
            Path        = myPath;
            return(result);
        }