public async Task <(bool success, SelectionResult result)> TrySelectAsync(string path, CancellationToken ct) { path = path.Replace(System.IO.Path.DirectorySeparatorChar, '/').Replace("//", "/"); string fullPath = FullPath(path); LocalDiskEntry ldd = null; if (DocDict.ContainsKey(fullPath)) { ldd = DocDict[fullPath]; } else if (ColDict.ContainsKey(fullPath)) { ldd = ColDict[fullPath]; } SelectionResult sel = null; if (ldd == null) { if (path.Any()) { string[] comps = path.Split('/'); ICollection found = FastRoot; IEntry tmp = null; int index = 0; do { tmp = await found.GetChildAsync(comps[index], ct); if (tmp != null) { index++; if (tmp is ICollection) { found = tmp as ICollection; } } } while(tmp != null && tmp is ICollection && index < comps.Length); string[] missingComps = comps.Skip(index).Select(x => x + '/').ToArray(); if (!missingComps.Any()) { ldd = tmp as LocalDiskEntry; } else { if (path.Last() != '/') { sel = SelectionResult.CreateMissingDocumentOrCollection(found, missingComps); } else { sel = SelectionResult.CreateMissingCollection(found, missingComps); } } } else { ICollection col = await Root.Task; sel = SelectionResult.Create(col); } } if (ldd != null && ldd is ICollection) { sel = SelectionResult.Create(ldd as ICollection); } else if (ldd != null) { sel = SelectionResult.Create((ldd as LocalDiskDocument).Parent, ldd as LocalDiskDocument); } return(ldd != null, sel); }
internal override void RemoveFromDict() { ColDict?.Remove(AbsolutePath); }