public IEnumerable <DocumentAddress> GetAddresses( DocumentRoute route, DocumentSearchOption options) { var directory = GetDirectoryPath(route); if (!Directory.Exists(directory)) { return(Enumerable.Empty <DocumentAddress>()); } SearchOption searchOption = options switch { DocumentSearchOption.TopLevelOnly => SearchOption.TopDirectoryOnly, DocumentSearchOption.AllLevels => SearchOption.AllDirectories, _ => throw new ArgumentException($"Invalid {nameof(options)}: {options}") }; return(Directory .EnumerateFiles( path: directory, searchPattern: "*" + fileExtension, searchOption: searchOption ) .Select(path => // abs -> rel path.Replace(directory, String.Empty)) .Select(GetAddress) .Select(relAddress => // rel -> abs relAddress.MapRoute(relRoute => relRoute.Prepend(route)))); }
/// <summary> /// Returns addresses, associated to documents of <typeparamref name="TData"/>. /// </summary> public static Task <IEnumerable <DocumentAddress> > GetAddressesAsync <TData>( this IDocumentStore store, DocumentSearchOption options = DocumentSearchOption.AllLevels, CancellationToken ct = default) where TData : class { if (store == null) { throw new ArgumentNullException(nameof(store)); } return(store.GetAddressesAsync <TData>(DocumentRoute.Default, options, ct)); }
public IEnumerable <DocumentAddress> GetAddresses(DocumentRoute route, DocumentSearchOption options) => source.GetAddresses(translateIn(route), options).Select(TranslateOut);
public InvalidDocumentSearchOptionsException(DocumentSearchOption options) : base("InvalidOptions: " + options.ToString()) { }
Task <IEnumerable <DocumentAddress> > IDocumentStore.GetAddressesAsync <TData>( DocumentRoute topicName, DocumentSearchOption options, CancellationToken ct) where TData : class => store.GetAddressesAsync <TData>(topicName, options, ct);