public static IDictionary <T, T> ToDictionary <T>(this ISimpleTree <T> tree) where T : class
        {
            var nodes = tree.GetDescendantsIncludeSelf();

            var dict = new Dictionary <T, T>();

            foreach (var node in nodes)
            {
                if (node.IsRootNode)
                {
                    dict.Add(node.Data, null);
                }
                else
                {
                    dict.Add(node.Data, node.ParentNode.Data);
                }
            }

            return(dict);
        }
Exemple #2
0
 public static IList <ISimpleTree <TData> > Traverse <TData>(ISimpleTree <TData> tree)
 {
     return(TreeExtensions.Traverse <TData, ISimpleTree <TData> >(tree));
 }
Exemple #3
0
 public static IList <ISimpleTree <TData> > Traverse <TData>(
     ISimpleTree <TData> tree, Action <ISimpleTree <TData> > preAction, Action <ISimpleTree <TData> > postAction)
 {
     return(TreeExtensions.Traverse <TData, ISimpleTree <TData> >(tree, preAction, postAction));
 }