/// <summary>Opens the directory with the given <paramref name="path"/>. /// If the directory does not exist, and if <paramref name="readOnly"/> is false, it is created. Otherwise, this method returns null. /// If the <paramref name="layer"/> is specified, it is checked against the layer of an existing directory or set as the layer of a new directory. /// </summary> /// <param name="directory">Parent directory</param> /// <param name="trans">Transaction used by the operation</param> /// <param name="path">Path to the directory to open or create</param> /// <param name="readOnly">If true, do not make any modifications to the database, and return null if the directory does not exist.</param> /// <param name="layer">Optional layer ID that is checked with the opened directory.</param> /// <returns></returns> public static Task <FdbDirectorySubspace> TryCreateOrOpenAsync([NotNull] this IFdbDirectory directory, [NotNull] IFdbTransaction trans, FdbDirectoryPath path, bool readOnly, Slice layer = default) { Contract.NotNull(directory, nameof(directory)); Contract.NotNull(trans, nameof(trans)); return(readOnly ? directory.TryOpenAsync(trans, path, layer) : directory.CreateOrOpenAsync(trans, path, layer)); }
/// <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)); }
/// <summary>Attempts to open the directory with the given <paramref name="name"/>.</summary> public static Task <FdbDirectorySubspace> TryOpenAsync([NotNull] this IFdbDirectory directory, [NotNull] IFdbReadOnlyTransaction trans, [NotNull] string name, Slice layer) { 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.TryOpenAsync(trans, new[] { name }, layer)); }
/// <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 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 }, layer), ct)); }
/// <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, 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.TryOpenAsync(tr, path, Slice.Nil), ct)); }
/// <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 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 }, Slice.Nil), cancellationToken)); }
/// <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)); }
/// <summary>Opens the directory with the given <paramref name="path"/>. /// If the directory does not exist, and if <paramref name="readOnly"/> is false, it is created. Otherwise, this method returns null. /// If the <paramref name="layer"/> is specified, it is checked against the layer of an existing directory or set as the layer of a new directory. /// </summary> /// <param name="directory">Parent directory</param> /// <param name="trans">Transaction used by the operation</param> /// <param name="path">Path to the directory to open or create</param> /// <param name="readOnly">If true, do not make any modifications to the database, and return null if the directory does not exist.</param> /// <param name="layer">Optional layer ID that is checked with the opened directory.</param> /// <returns></returns> public static Task <FdbDirectorySubspace> TryCreateOrOpenAsync([NotNull] this IFdbDirectory directory, [NotNull] IFdbTransaction trans, [NotNull] IEnumerable <string> path, bool readOnly, Slice layer = default(Slice)) { if (directory == null) { throw new ArgumentNullException(nameof(directory)); } if (trans == null) { throw new ArgumentNullException(nameof(trans)); } if (path == null) { throw new ArgumentNullException(nameof(path)); } if (readOnly) { return(directory.TryOpenAsync(trans, path, layer)); } else { return(directory.CreateOrOpenAsync(trans, path, layer)); } }
/// <summary>Opens a subdirectory with the given <paramref name="name"/>. /// An exception is thrown if the subdirectory 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> /// <returns>Returns the directory if it exists, or null if it was not found</returns> public Task <FdbDirectorySubspace> TryOpenAsync([NotNull] string name, CancellationToken cancellationToken) { return(m_database.ReadAsync((tr) => m_directory.TryOpenAsync(tr, new [] { name }, Slice.Nil), cancellationToken)); }