/// <summary> /// </summary> /// <param name="Path"></param> public VirtualFileSystemNode InsertNode(string Path, DateTime CreateTime, object Metadata = null) { VirtualFileSystemNode ParentNode = Root; string ParentPath = GetParentPath(Path); if (ParentPath.Length > 0) { ParentNode = InsertNode(ParentPath, CreateTime); } string NodeName = GetNodeName(Path); VirtualFileSystemNode Child = ParentNode.GetChildByName(NodeName); if (Child == null) { Child = new VirtualFileSystemNode(NodeName, Path, CreateTime, ParentNode, Metadata); ParentNode.Children.Add(Child); ParentNode.SortChildren(); OnNodeAdded?.Invoke(this, Child); } else { Child.Metadata = Metadata; } return(Child); }
/// <summary> /// </summary> /// <returns></returns> public VirtualFileSystemNode GetNodeByPath(string Path) { if (Path.Length == 0) { RefreshNodeChildren(Root); return(Root); } VirtualFileSystemNode ParentNode = Root; string ParentPath = GetParentPath(Path); if (ParentPath.Length > 0) { ParentNode = GetNodeByPath(ParentPath); } if (ParentNode == null) { return(null); } RefreshNodeChildren(ParentNode); string NodeName = GetNodeName(Path); return(ParentNode.GetChildByName(NodeName)); }