private void PerformAsyncUow(IInvocation invocation, UnitOfWorkOptions options) { var uow = _unitOfWorkManager.Begin(options); invocation.Proceed(); if (invocation.Method.ReturnType == typeof(Task)) { invocation.ReturnValue = InternalAsyncHelper.AwaitTaskWithPostActionAndFinally( (Task)invocation.ReturnValue, async() => await uow.CompleteAsync(), exception => uow.Dispose() ); } else //Task<TResult> { invocation.ReturnValue = InternalAsyncHelper.CallAwaitTaskWithPostActionAndFinallyAndGetResult( invocation.Method.ReturnType.GenericTypeArguments[0], invocation.ReturnValue, async() => await uow.CompleteAsync(), (exception) => uow.Dispose() ); } }
public IUnitOfWorkCompleteHandle Begin(UnitOfWorkOptions options) { options.FillDefaultsForNonProvidedOptions(defaultOptions); IDirectUnitOfWork uow = iocResolver.Resolve <IDirectUnitOfWork>(); uow.Completed += (sender, args) => { currentUnitOfWorkProvider.Current = null; }; uow.Failed += (sender, args) => { currentUnitOfWorkProvider.Current = null; }; uow.Disposed += (sender, args) => { iocResolver.Release(uow); }; uow.Begin(options); currentUnitOfWorkProvider.Current = uow; return(uow); }
public void Begin(UnitOfWorkOptions options) { options.IsTransactional = false; internalUow.Begin(options); }