/// <summary>Opens the directory with the given <paramref name="path"/>. /// An error is raised if the directory does not exist, or if a layer is specified and a different layer was specified when the directory was created. /// </summary> public static Task <FdbDirectorySubspace> OpenAsync([NotNull] this IFdbDirectory directory, [NotNull] IFdbRetryable db, FdbDirectoryPath path, Slice layer, CancellationToken ct) { Contract.NotNull(directory, nameof(directory)); Contract.NotNull(db, nameof(db)); return(db.ReadAsync((tr) => directory.OpenAsync(tr, path, layer), ct)); }
public static async Task <Dictionary <string, FdbDirectorySubspace> > BrowseAsync([NotNull] IFdbDatabase db, [NotNull] IFdbDirectory parent, CancellationToken cancellationToken) { if (db == null) { throw new ArgumentNullException("db"); } if (parent == null) { throw new ArgumentNullException("parent"); } return(await db.ReadAsync(async (tr) => { // read the names of all the subdirectories var names = await parent.ListAsync(tr).ConfigureAwait(false); // open all the subdirectories var folders = await names .ToAsyncEnumerable() .SelectAsync((name, ct) => parent.OpenAsync(tr, name)) .ToListAsync(); // map the result return folders.ToDictionary(ds => ds.Name); }, cancellationToken).ConfigureAwait(false)); }
/// <summary>Opens the sub-directory with the given <paramref name="name"/>. /// An error is raised if the directory does not exist, or if a layer is specified and a different layer was specified when the directory was created. /// </summary> public static Task <FdbDirectorySubspace> OpenAsync([NotNull] this IFdbDirectory directory, [NotNull] IFdbReadOnlyTransaction trans, [NotNull] string name, Slice layer = default(Slice)) { if (directory == null) { throw new ArgumentNullException(nameof(directory)); } if (trans == null) { throw new ArgumentNullException(nameof(trans)); } if (name == null) { throw new ArgumentNullException(nameof(name)); } return(directory.OpenAsync(trans, new[] { name }, layer)); }
/// <summary>Opens the sub-directory with the given <paramref name="name"/>. /// An error is raised if the directory does not exist, or if a layer is specified and a different layer was specified when the directory was created. /// </summary> public static Task <FdbDirectorySubspace> OpenAsync([NotNull] this IFdbDirectory directory, [NotNull] IFdbRetryable db, [NotNull] string name, Slice layer, CancellationToken ct) { if (directory == null) { throw new ArgumentNullException(nameof(directory)); } if (db == null) { throw new ArgumentNullException(nameof(db)); } if (name == null) { throw new ArgumentNullException(nameof(name)); } return(db.ReadAsync((tr) => directory.OpenAsync(tr, new[] { name }, layer), ct)); }
/// <summary>Opens the directory with the given <paramref name="path"/>. /// An error is raised if the directory does not exist. /// </summary> public static Task <FdbDirectorySubspace> OpenAsync([NotNull] this IFdbDirectory directory, [NotNull] IFdbRetryable db, [NotNull] IEnumerable <string> path, CancellationToken ct) { if (directory == null) { throw new ArgumentNullException(nameof(directory)); } if (db == null) { throw new ArgumentNullException(nameof(db)); } if (path == null) { throw new ArgumentNullException(nameof(path)); } return(db.ReadAsync((tr) => directory.OpenAsync(tr, path, Slice.Nil), ct)); }
/// <summary>Opens the sub-directory with the given <paramref name="name"/>. /// An error is raised if the directory does not exist. /// </summary> public static Task <FdbDirectorySubspace> OpenAsync([NotNull] this IFdbDirectory directory, [NotNull] IFdbRetryable db, [NotNull] string name, CancellationToken cancellationToken) { if (directory == null) { throw new ArgumentNullException("directory"); } if (db == null) { throw new ArgumentNullException("db"); } if (name == null) { throw new ArgumentNullException("name"); } return(db.ReadAsync((tr) => directory.OpenAsync(tr, new[] { name }, Slice.Nil), cancellationToken)); }
/// <summary>Opens the directory with the given <paramref name="path"/>. /// An error is raised if the directory does not exist, or if a layer is specified and a different layer was specified when the directory was created. /// </summary> public static Task <FdbDirectorySubspace> OpenAsync([NotNull] this IFdbDirectory directory, [NotNull] IFdbRetryable db, [NotNull] IEnumerable <string> path, Slice layer, CancellationToken cancellationToken) { if (directory == null) { throw new ArgumentNullException("directory"); } if (db == null) { throw new ArgumentNullException("db"); } if (path == null) { throw new ArgumentNullException("path"); } return(db.ReadAsync((tr) => directory.OpenAsync(tr, path, layer), cancellationToken)); }
/// <summary>List and open the sub-directories of the given directory</summary> /// <param name="tr">Transaction used for the operation</param> /// <param name="parent">Parent directory</param> /// <returns>Dictionary of all the sub directories of the <paramref name="parent"/> directory.</returns> public static async Task <Dictionary <string, FdbDirectorySubspace> > BrowseAsync(IFdbReadOnlyTransaction tr, IFdbDirectory parent) { Contract.NotNull(tr, nameof(tr)); Contract.NotNull(parent, nameof(parent)); // read the names of all the subdirectories var children = await parent.ListAsync(tr).ConfigureAwait(false); // open all the subdirectories var folders = await children .ToAsyncEnumerable() .SelectAsync((child, _) => parent.OpenAsync(tr, FdbPath.Relative(child.Name))) .ToListAsync(); // map the result return(folders.ToDictionary(ds => ds.Name)); }
public static async Task <Dictionary <string, FdbDirectorySubspace> > BrowseAsync([NotNull] IFdbDatabase db, [NotNull] IFdbDirectory parent, CancellationToken ct) { Contract.NotNull(db, nameof(db)); Contract.NotNull(parent, nameof(parent)); return(await db.ReadAsync(async (tr) => { // read the names of all the subdirectories var names = await parent.ListAsync(tr).ConfigureAwait(false); // open all the subdirectories var folders = await names .ToAsyncEnumerable() .SelectAsync((name, _) => parent.OpenAsync(tr, name)) .ToListAsync(ct); // map the result return folders.ToDictionary(ds => ds.Name); }, ct).ConfigureAwait(false)); }
/// <summary>Opens a subdirectory with the given <paramref name="name"/>. /// An exception is thrown if the subdirectory does not exist, or if a layer is specified and a different layer was specified when the subdirectory was created. /// </summary> /// <param name="name">Name of the subdirectory to open</param> public Task <FdbDirectorySubspace> OpenAsync([NotNull] string name, CancellationToken cancellationToken) { return(m_database.ReadAsync((tr) => m_directory.OpenAsync(tr, new [] { name }, Slice.Nil), cancellationToken)); }