Beispiel #1
0
 internal static BrowserItemModel CreateBrowserItemModel(BrowserModel parent, BrowserTree tree)
 {
     return(tree.Type switch
     {
         BrowserEntryType.Directory => new BrowserFolderItemModel(parent, tree),
         BrowserEntryType.RegularFile => new BrowserFileItemModel(parent, tree),
         _ => throw new IndexOutOfRangeException("Type not in enum."),
     });
Beispiel #2
0
 private void AddEntry(string entry)
 {
     if (!entry.Contains('/'))
     {
         _children.Add(new BrowserTree(this, entry, BrowserEntryType.RegularFile));
     }
     else
     {
         if (entry[0] == '/')
         {
             entry = entry.Substring(1);
         }
         int         index = entry.IndexOf('/');
         string      dir   = entry.Substring(0, index);
         BrowserTree child = _children.Find(tree => tree._entryName == dir);
         if (child == null)
         {
             child = new BrowserTree(this, dir, BrowserEntryType.Directory);
             _children.Add(child);
         }
         child.AddEntry(entry.Substring(index + 1));
     }
 }
Beispiel #3
0
 private BrowserTree(BrowserTree parent, string entryName, BrowserEntryType type)
 {
     _parent    = parent;
     _entryName = entryName;
     _type      = type;
 }
Beispiel #4
0
 protected BrowserItemModel(BrowserModel parent, BrowserTree tree)
 {
     _parent = parent;
     _tree   = tree;
     _name   = tree.Name;
 }