Ejemplo n.º 1
0
 /// <summary>Returns the list of subdirectories of the sub-directory with the given <paramref name="name"/>.</summary>
 public static Task <List <string> > ListAsync([NotNull] this IFdbDirectory directory, [NotNull] IFdbReadOnlyRetryable 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.ListAsync(tr, new [] { name }), cancellationToken));
 }
Ejemplo n.º 2
0
        /// <summary>Attempts to open the directory with the given <paramref name="path"/>.</summary>
        public static Task <FdbDirectorySubspace> TryOpenAsync([NotNull] this IFdbDirectory directory, [NotNull] IFdbReadOnlyRetryable db, FdbDirectoryPath path, Slice layer, CancellationToken ct)
        {
            Contract.NotNull(directory, nameof(directory));
            Contract.NotNull(db, nameof(db));

            return(db.ReadAsync((tr) => directory.TryOpenAsync(tr, path, layer), ct));
        }
Ejemplo n.º 3
0
        /// <summary>Checks if this directory exists</summary>
        /// <returns>Returns true if the directory exists, otherwise false.</returns>
        public static Task <bool> ExistsAsync([NotNull] this FdbDirectorySubspace subspace, [NotNull] IFdbReadOnlyRetryable db, CancellationToken cancellationToken)
        {
            if (subspace == null)
            {
                throw new ArgumentNullException("subspace");
            }
            if (db == null)
            {
                throw new ArgumentNullException("db");
            }

            return(db.ReadAsync((tr) => subspace.ExistsAsync(tr), cancellationToken));
        }
Ejemplo n.º 4
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));
        }
Ejemplo n.º 5
0
        /// <summary>Attempts to open the directory with the given <paramref name="path"/>.</summary>
        public static Task <FdbDirectorySubspace> TryOpenAsync([NotNull] this IFdbDirectory directory, [NotNull] IFdbReadOnlyRetryable 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.TryOpenAsync(tr, path, layer), cancellationToken));
        }
Ejemplo n.º 6
0
        /// <summary>Attempts to open the directory with the given <paramref name="name"/>.</summary>
        public static Task <FdbDirectorySubspace> TryOpenAsync([NotNull] this IFdbDirectory directory, [NotNull] IFdbReadOnlyRetryable db, [NotNull] string name, Slice layer, 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.TryOpenAsync(tr, new[] { name }, layer), cancellationToken));
        }
Ejemplo n.º 7
0
        /// <summary>Attempts to open the directory with the given <paramref name="name"/>.</summary>
        public static Task <FdbDirectorySubspace> TryOpenAsync([NotNull] this IFdbDirectory directory, [NotNull] IFdbReadOnlyRetryable db, [NotNull] string name, 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.TryOpenAsync(tr, new[] { name }, Slice.Nil), ct));
        }
Ejemplo n.º 8
0
 /// <summary>Resolve a single key selector from the database, using a dedicated transaction.</summary>
 /// <param name="db">Database instance</param>
 /// <remarks>
 /// Use this method only if you intend to perform a single operation inside your execution context (ex: HTTP request).
 /// If you need to combine multiple read or write operations, consider using on of the multiple <see cref="IFdbReadOnlyRetryable.ReadAsync"/> or <see cref="IFdbRetryable.ReadWriteAsync"/> overrides.
 /// </remarks>
 public static Task <Slice> GetKeyAsync([NotNull] this IFdbReadOnlyRetryable db, KeySelector keySelector, CancellationToken ct)
 {
     Contract.NotNull(db, nameof(db));
     return(db.ReadAsync((tr) => tr.GetKeyAsync(keySelector), ct));
 }
Ejemplo n.º 9
0
 /// <summary>Returns the list of subdirectories of directory at <paramref name="path"/>, if it exists</summary>
 public static Task <List <string> > TryListAsync([NotNull] this IFdbDirectory directory, [NotNull] IFdbReadOnlyRetryable db, 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));                           //REVIEW: or not?
     }
     return(db.ReadAsync((tr) => directory.TryListAsync(tr, path), ct));
 }
Ejemplo n.º 10
0
        /// <summary>Returns the list of all the subdirectories of the current directory, it it exists.</summary>
        public static Task <List <string> > TryListAsync([NotNull] this FdbDirectorySubspace subspace, [NotNull] IFdbReadOnlyRetryable db, CancellationToken ct)
        {
            if (subspace == null)
            {
                throw new ArgumentNullException(nameof(subspace));
            }
            if (db == null)
            {
                throw new ArgumentNullException(nameof(db));
            }

            return(db.ReadAsync((tr) => subspace.TryListAsync(tr), ct));
        }
Ejemplo n.º 11
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)
 {
     if (directory == null)
     {
         throw new ArgumentNullException(nameof(directory));
     }
     if (db == null)
     {
         throw new ArgumentNullException(nameof(db));
     }
     return(db.ReadAsync((tr) => directory.ListAsync(tr), ct));
 }
Ejemplo n.º 12
0
 /// <summary>Read a single page of a range query from the database, using a dedicated transaction.</summary>
 /// <param name="db">Database instance</param>
 /// <remarks>
 /// Use this method only if you intend to perform a single operation inside your execution context (ex: HTTP request).
 /// If you need to combine multiple read or write operations, consider using on of the multiple <see cref="IFdbReadOnlyRetryable.ReadAsync"/> or <see cref="IFdbRetryable.ReadWriteAsync"/> overrides.
 /// </remarks>
 public static Task <FdbRangeChunk> GetRangeAsync([NotNull] this IFdbReadOnlyRetryable db, KeySelector beginInclusive, KeySelector endExclusive, FdbRangeOptions options, int iteration, CancellationToken ct)
 {
     Contract.NotNull(db, nameof(db));
     return(db.ReadAsync((tr) => tr.GetRangeAsync(beginInclusive, endExclusive, options, iteration), ct));
 }
Ejemplo n.º 13
0
 public static Task <Slice[]> GetKeysAsync([NotNull] this IFdbReadOnlyRetryable db, [NotNull] IEnumerable <KeySelector> keySelectors, CancellationToken ct)
 {
     Contract.NotNull(db, nameof(db));
     Contract.NotNull(keySelectors, nameof(keySelectors));
     return(db.ReadAsync((tr) => tr.GetKeysAsync(keySelectors), ct));
 }
Ejemplo n.º 14
0
        /// <summary>Removes the directory, its contents, and all subdirectories.
        #endregion

        #region Exists...

        /// <summary>Checks if a directory already exists</summary>
        /// <returns>Returns true if the directory exists, otherwise false.</returns>
        public static Task <bool> ExistsAsync([NotNull] this IFdbDirectory directory, [NotNull] IFdbReadOnlyRetryable db, FdbDirectoryPath path, CancellationToken ct)
        {
            Contract.NotNull(directory, nameof(directory));
            Contract.NotNull(db, nameof(db));

            return(db.ReadAsync((tr) => directory.ExistsAsync(tr, path), ct));
        }
Ejemplo n.º 15
0
        /// <summary>Checks if a directory already exists</summary>
        /// <returns>Returns true if the directory exists, otherwise false.</returns>
        public static Task <bool> ExistsAsync([NotNull] this IFdbDirectory directory, [NotNull] IFdbReadOnlyRetryable db, [NotNull] string name, 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.ExistsAsync(tr, new[] { name }), ct));
        }
Ejemplo n.º 16
0
        /// <summary>Checks if this directory exists</summary>
        /// <returns>Returns true if the directory exists, otherwise false.</returns>
        public static Task <bool> ExistsAsync([NotNull] this FdbDirectorySubspace subspace, [NotNull] IFdbReadOnlyRetryable db, CancellationToken ct)
        {
            Contract.NotNull(subspace, nameof(subspace));
            Contract.NotNull(db, nameof(db));

            return(db.ReadAsync((tr) => subspace.ExistsAsync(tr), ct));
        }
Ejemplo n.º 17
0
 public static Task <Slice[]> GetValuesAsync([NotNull] this IFdbReadOnlyRetryable db, [NotNull] Slice[] keys, CancellationToken ct)
 {
     Contract.NotNull(db, nameof(db));
     return(db.ReadAsync((tr) => tr.GetValuesAsync(keys), ct));
 }