Inheritance: FdbSubspace, IFdbDirectory
コード例 #1
0
        /// <summary>Change the layer id of this directory</summary>
        public static Task <FdbDirectorySubspace> ChangeLayerAsync([NotNull] this FdbDirectorySubspace subspace, [NotNull] IFdbRetryable db, Slice newLayer, CancellationToken ct)
        {
            Contract.NotNull(subspace, nameof(subspace));
            Contract.NotNull(db, nameof(db));

            return(db.ReadWriteAsync((tr) => subspace.ChangeLayerAsync(tr, newLayer), ct));
        }
コード例 #2
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)
        {
            Contract.NotNull(subspace, nameof(subspace));
            Contract.NotNull(db, nameof(db));

            return(db.ReadAsync((tr) => subspace.TryListAsync(tr), ct));
        }
コード例 #3
0
        /// <summary>Attempts to move the current directory to <paramref name="newPath"/>.
        /// There is no effect on the physical prefix of the given directory, or on clients that already have the directory open.
        /// </summary>
        public static Task <FdbDirectorySubspace> TryMoveToAsync([NotNull] this FdbDirectorySubspace subspace, [NotNull] IFdbRetryable db, FdbDirectoryPath newPath, CancellationToken ct)
        {
            Contract.NotNull(subspace, nameof(subspace));
            Contract.NotNull(db, nameof(db));

            return(db.ReadWriteAsync((tr) => subspace.TryMoveToAsync(tr, newPath), ct));
        }
コード例 #4
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)
        {
            if (subspace == null)
            {
                throw new ArgumentNullException(nameof(subspace));
            }
            if (db == null)
            {
                throw new ArgumentNullException(nameof(db));
            }

            return(db.ReadAsync((tr) => subspace.ExistsAsync(tr), ct));
        }
コード例 #5
0
        /// <summary>Change the layer id of this directory</summary>
        public static Task <FdbDirectorySubspace> ChangeLayerAsync([NotNull] this FdbDirectorySubspace subspace, [NotNull] IFdbRetryable db, Slice newLayer, CancellationToken ct)
        {
            if (subspace == null)
            {
                throw new ArgumentNullException(nameof(subspace));
            }
            if (db == null)
            {
                throw new ArgumentNullException(nameof(db));
            }

            return(db.ReadWriteAsync((tr) => subspace.ChangeLayerAsync(tr, newLayer), ct));
        }
コード例 #6
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 cancellationToken)
        {
            if (subspace == null)
            {
                throw new ArgumentNullException("subspace");
            }
            if (db == null)
            {
                throw new ArgumentNullException("db");
            }

            return(db.ReadAsync((tr) => subspace.TryListAsync(tr), cancellationToken));
        }
コード例 #7
0
        /// <summary>Attempts to move the current directory to <paramref name="newPath"/>.
        /// There is no effect on the physical prefix of the given directory, or on clients that already have the directory open.
        /// </summary>
        public static Task <FdbDirectorySubspace> TryMoveToAsync([NotNull] this FdbDirectorySubspace subspace, [NotNull] IFdbRetryable db, [NotNull] IEnumerable <string> newPath, CancellationToken ct)
        {
            if (subspace == null)
            {
                throw new ArgumentNullException(nameof(subspace));
            }
            if (db == null)
            {
                throw new ArgumentNullException(nameof(db));
            }
            if (newPath == null)
            {
                throw new ArgumentNullException(nameof(newPath));
            }

            return(db.ReadWriteAsync((tr) => subspace.TryMoveToAsync(tr, newPath), ct));
        }
コード例 #8
0
		private static async Task TreeDirectoryWalk(FdbDirectorySubspace folder, List<bool> last, IFdbDatabase db, TextWriter stream, CancellationToken ct)
		{
			ct.ThrowIfCancellationRequested();

			var sb = new StringBuilder(last.Count * 4);
			if (last.Count > 0)
			{
				for (int i = 0; i < last.Count - 1; i++) sb.Append(last[i] ? "    " : "|   ");
				sb.Append(last[last.Count - 1] ? "`-- " : "|-- ");
			}

			IFdbDirectory node;
			if (folder == null)
			{
				stream.WriteLine(sb.ToString() + "<root>");
				node = db.Directory;
			}
			else
			{
				stream.WriteLine(sb.ToString() + (folder.Layer.ToString() == "partition" ? ("<" + folder.Name + ">") : folder.Name) + (folder.Layer.IsNullOrEmpty ? String.Empty : (" [" + folder.Layer.ToString() + "]")));
				node = folder;
			}

			var children = await Fdb.Directory.BrowseAsync(db, node, ct);
			int n = children.Count;
			foreach (var child in children)
			{
				last.Add((n--) == 1);
				await TreeDirectoryWalk(child.Value, last, db, stream, ct);
				last.RemoveAt(last.Count - 1);
			}
		}