示例#1
0
        /// <summary>Returns the list of subdirectories of directory at <paramref name="path"/>.</summary>
        public static Task <List <string> > ListAsync([NotNull] this IFdbDirectory directory, [NotNull] IFdbReadOnlyRetryable db, [NotNull] IEnumerable <string> path, 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.ListAsync(tr, path), 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);
                Contract.NotNull(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));
            }
示例#4
0
 /// <summary>Returns the list of all the top level directories of this database instance.</summary>
 public Task <List <string> > ListAsync(CancellationToken cancellationToken)
 {
     return(m_database.ReadWriteAsync((tr) => m_directory.ListAsync(tr), cancellationToken));
 }
示例#5
0
 /// <summary>Returns the list of subdirectories of the current directory.</summary>
 public static Task <List <string> > ListAsync([NotNull] this IFdbDirectory directory, [NotNull] IFdbReadOnlyRetryable db, CancellationToken ct)
 {
     Contract.NotNull(directory, nameof(directory));
     Contract.NotNull(db, nameof(db));
     return(db.ReadAsync((tr) => directory.ListAsync(tr), ct));
 }