Recently developing family library management. Original idea was to perform hierarchical management of family library through left right interpolation. Later simulated and found that for large number of new project family libraries added later, there will be a lot of burden, so recorded this idea method for people in need.
If not involving large batch modification, can use this method. But probably only standard hard coding etc. in the whole housing construction industry can be suitable.
Left right value comparison relationship is mainly same as picture below
Image Description
Detailed content can see this blog: Left right value coding storage infinite hierarchical tree structure design

The example below is creating tree structure by traversing family library according to left right interpolation. Mainly recording idea. Some methods inside are structure created by myself.
Calculation is mainly through

  1. Non-lowest hierarchy, determine right value through total file amount below and left value
  2. Lowest hierarchy, confirm through self-decrement of left value and right value
    Image Description
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
    /// Reference i value, and set left right values
/// </summary>
/// <param name="df"></param>
/// <param name="i"></param>
/// <returns></returns>
private DirFolders GetAllFiles(DirFolders df,ref int i)
{
for(int j=0;j<files.Length-1;j++)
{
var fileInfo = files[j];
var str = Path.GetFileNameWithoutExtension(fileInfo.DirectoryName+@"\"+fileInfo.Name);
var extension = fileInfo.Extension;
DirFolders folder = new DirFolders(str, (fileInfo.DirectoryName + "\\" + fileInfo.Name));
folder.SetIcon(new BitmapImage(new Uri("/Resources/R_round_r.jpg", UriKind.Relative)));
folder.IsRfaFile = true;
folder.Left = ++i;
folder.Right = df.Right - (j + 1);
folder.SetThumbnail(
new GetThumbnail(fileInfo.DirectoryName + "\\" + fileInfo.Name).GetImage());

df.SetSub(folder);
}

return df;
}
/// <summary>
/// Calculate right value when uploading database
/// </summary>
/// <param name="left"></param>
/// <param name="size"></param>
/// <returns></returns>
private static int CalculationRight(int left, int size)
{
//size = (right-left-1)/2
return 2 * size + 1 + left;
}

private static int GetAllFiles(DirectoryInfo dirInfo)
{
int i = 0;
var filesCount = dirInfo.GetFiles("*.rfa");
i += filesCount.Length;
var foldersCount = dirInfo.GetDirectories();
i += foldersCount.Length;
foreach (var directoryInfo in foldersCount)
{
i += GetAllFiles(directoryInfo);
}

return i-1;
}
}