/// <summary> /// Gets an <see cref="IUnitOfWork"/> from the given <see cref="IUnitOfWorkFactory"/> and, after /// executing the function asynchronously, releases the UoW instance and returns the value /// </summary> /// <typeparam name="TUoW">The <see cref="IUnitOfWork"/> type</typeparam> /// <typeparam name="T">The result type</typeparam> /// <param name="factory">The factory to be used</param> /// <param name="toExecute">The action to be executed</param> /// <param name="ct">The cancellation token</param> /// <returns>A task that can be awaited for the result</returns> /// <exception cref="ArgumentNullException"/> public static async Task <T> GetAndReleaseAsync <TUoW, T>( this IUnitOfWorkFactory factory, Func <TUoW, CancellationToken, Task <T> > toExecute, CancellationToken ct = default(CancellationToken)) where TUoW : IUnitOfWork { return(await factory.GetAndReleaseAsync <IUnitOfWorkFactory, TUoW, T>(toExecute, ct)); }
/// <summary> /// Gets an <see cref="IUnitOfWork"/> from the given <see cref="IUnitOfWorkFactory"/> and, after /// executing the function asynchronously, releases the UoW instance and returns the value /// </summary> /// <typeparam name="TUoW">The <see cref="IUnitOfWork"/> type</typeparam> /// <typeparam name="T">The result type</typeparam> /// <param name="factory">The factory to be used</param> /// <param name="toExecute">The action to be executed</param> /// <returns>A task that can be awaited for the result</returns> /// <exception cref="ArgumentNullException"/> public static async Task <T> GetAndReleaseAsync <TUoW, T>(this IUnitOfWorkFactory factory, Func <TUoW, Task <T> > toExecute) where TUoW : IUnitOfWork { return(await factory.GetAndReleaseAsync <IUnitOfWorkFactory, TUoW, T>(toExecute)); }
/// <summary> /// Gets an <see cref="IUnitOfWork"/> from the given <see cref="IUnitOfWorkFactory"/> and, after /// executing the function asynchronously, releases the UoW instance. /// </summary> /// <typeparam name="TUoW">The <see cref="IUnitOfWork"/> type</typeparam> /// <param name="factory">The factory to be used</param> /// <param name="toExecute">The action to be executed</param> /// <returns>A task that can be awaited</returns> /// <exception cref="ArgumentNullException"/> public static async Task GetAndReleaseAsync <TUoW>( this IUnitOfWorkFactory factory, Func <TUoW, Task> toExecute) where TUoW : IUnitOfWork { await factory.GetAndReleaseAsync <IUnitOfWorkFactory, TUoW>(toExecute); }