/// <summary> /// intercept as an asynchronous operation. /// </summary> /// <param name="invocation">The invocation.</param> /// <returns>Task.</returns> public override async Task InterceptAsync(IMethodInvocation invocation) { if (!UnitOfWorkHelper.IsUnitOfWorkMethod(invocation.Method, out var unitOfWorkAttribute)) { await invocation.ProceedAsync(); return; } using (var uow = _unitOfWorkManager.Begin(CreateOptions(invocation, unitOfWorkAttribute))) { await invocation.ProceedAsync(); await uow.CompleteAsync(); } }
/// <summary> /// Shoulds the intercept. /// </summary> /// <param name="type">The type.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> private static bool ShouldIntercept(Type type) { return(!DynamicProxyIgnoreTypes.Contains(type) && UnitOfWorkHelper.IsUnitOfWorkType(type.GetTypeInfo())); }