public async IAsyncEnumerable <PropfindResult> EnumeratePropertiesInternal(IAsyncEnumerable <PropfindResult> backenditems, OperationDepth depth, bool getAllProps, IEnumerable <XName> additionalProps) { await foreach (var item in backenditems) { foreach (var(orig, newext, replace, _, newMime) in rules) { if (item.Path.EndsWith(orig, StringComparison.InvariantCultureIgnoreCase)) { if (replace) { item.Path = item.Path.Substring(0, item.Path.Length - orig.Length) + newext; if (newMime != null) { item[Name.GetContentType] = newMime; } } else { var ni = new PropfindResult(item); ni.Path = item.Path.Substring(0, item.Path.Length - orig.Length) + newext; if (newMime != null) { ni[Name.GetContentType] = newMime; } yield return(ni); } break; } } yield return(item); } }
public Task <IAsyncEnumerable <PropfindResult>?> EnumerateProperties(string path, OperationDepth depth, bool getAllProps, IEnumerable <XName> additionalProps) { var query = QueryFromPath(path); if (!Index.TryGetItem(query, out var rootItem)) { return(Task.FromResult <IAsyncEnumerable <PropfindResult>?>(null)); } else { return(Task.FromResult <IAsyncEnumerable <PropfindResult>?>(EnumerateProperties(rootItem, depth, getAllProps, additionalProps))); } }
public async Task <IAsyncEnumerable <PropfindResult>?> EnumerateProperties(string path, OperationDepth depth, bool getAllProps, IEnumerable <XName> additionalProps) { foreach (var(orig, newext, _, _, _) in rules) { if (path.EndsWith(newext, StringComparison.InvariantCultureIgnoreCase)) { path = path.Substring(0, path.Length - newext.Length) + orig; break; } } var backenditems = await backend.EnumerateProperties(path, depth, getAllProps, additionalProps); if (backenditems == null) { return(null); } return(EnumeratePropertiesInternal(backenditems, depth, getAllProps, additionalProps)); }