-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
43 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,43 @@ | ||
# PathToTreeConverter | ||
A simple class that converts a list of string paths to a tree model | ||
# What is this? | ||
A simple C# class that converts a list of string paths into a tree model. | ||
|
||
# How does that look? | ||
Given an input like: | ||
|
||
``` | ||
"//subFolder1", | ||
"//subFolder1//subsubfolder1a", | ||
"//subFolder1//subsubfolder1a//sub-sub-sub", | ||
"//subFolder2", | ||
"//subFolder2//subsubfolder1b" | ||
``` | ||
|
||
turns into: | ||
|
||
``` | ||
+ subFolder1 | ||
+ subsubfolder1a | ||
+ sub-sub-sub | ||
+ subFolder2 | ||
+ subsubfolder1b | ||
``` | ||
|
||
# How does that work? | ||
Easy... | ||
``` | ||
var paths = new[] | ||
{ | ||
"//subFolder1", | ||
"//subFolder1//subsubfolder1a", | ||
"//subFolder1//subsubfolder1a//sub-sub-sub", | ||
"//subFolder2", | ||
"//subFolder2//subsubfolder1b" | ||
}; | ||
var converter = new PathsToTreeConverter(); | ||
converter.SetDelimiterSymbol("//"); // "/" is default, otherwise use the SetDelimiterSymbol method | ||
var result = converter.Convert(paths); | ||
// now do something funky with your list of tree nodes | ||
``` |