public void Intercept(IInvocation invocation) { if (AbpCrossCuttingConcerns.IsApplied(invocation.InvocationTarget, AbpCrossCuttingConcerns.Auditing)) { invocation.Proceed(); return; } if (!_auditingHelper.ShouldSaveAudit(invocation.MethodInvocationTarget)) { invocation.Proceed(); return; } var auditInfo = _auditingHelper.CreateAuditInfo(invocation.TargetType, invocation.MethodInvocationTarget, invocation.Arguments); if (AsyncHelper.IsAsyncMethod(invocation.Method)) { PerformAsyncAuditing(invocation, auditInfo); } else { PerformSyncAuditing(invocation, auditInfo); } }
public void IsAsync_Should_Work() { AsyncHelper.IsAsyncMethod(GetType().GetMethod("MyMethod1Sync", BindingFlags.NonPublic | BindingFlags.Instance)).ShouldBe(false); AsyncHelper.IsAsyncMethod(GetType().GetMethod("MyMethod1Async", BindingFlags.NonPublic | BindingFlags.Instance)).ShouldBe(true); AsyncHelper.IsAsyncMethod(GetType().GetMethod("MyMethod2Sync", BindingFlags.NonPublic | BindingFlags.Instance)).ShouldBe(false); AsyncHelper.IsAsyncMethod(GetType().GetMethod("MyMethod2Async", BindingFlags.NonPublic | BindingFlags.Instance)).ShouldBe(true); }
public void Intercept(IInvocation invocation) { if (AbpCrossCuttingConcerns.IsApplied(invocation.InvocationTarget, AbpCrossCuttingConcerns.Auditing)) { invocation.Proceed(); return; } if (!AuditingHelper.ShouldSaveAudit(invocation.MethodInvocationTarget, _configuration, AbpSession)) { invocation.Proceed(); return; } var auditInfo = CreateAuditInfo(invocation); if (AsyncHelper.IsAsyncMethod(invocation.Method)) { PerformAsyncAuditing(invocation, auditInfo); } else { PerformSyncAuditing(invocation, auditInfo); } }
private void PerformUow(IInvocation invocation, UnitOfWorkOptions options) { if (AsyncHelper.IsAsyncMethod(invocation.Method)) { PerformAsyncUow(invocation, options); } else { PerformSyncUow(invocation, options); } }
/// <summary> /// Intercept /// </summary> /// <param name="invocation"></param> public void Intercept(IInvocation invocation) { if (AsyncHelper.IsAsyncMethod(invocation.Method)) { PerformUowAsync(invocation); } else { PerformUow(invocation); } }
private void ProccessUnitOfWork(IInvocation invocation) { if (AsyncHelper.IsAsyncMethod(invocation.Method)) { ProcceedAvailableTransactionsAsync(invocation); } else { ProcceedAvailableTransactions(invocation); } }
private void PerformUow(IInvocation invocation, bool isTransactional) { if (!AsyncHelper.IsAsyncMethod(invocation.Method)) { PerformSyncUow(invocation, isTransactional); } else { PerformAsyncUow(invocation, isTransactional); } }
public void Intercept(IInvocation invocation) { if (!AuditingHelper.ShouldSaveAudit(invocation.MethodInvocationTarget, _configuration, HozaruSession)) { invocation.Proceed(); return; } var auditInfo = CreateAuditInfo(invocation); if (AsyncHelper.IsAsyncMethod(invocation.Method)) { PerformAsyncAuditing(invocation, auditInfo); } else { PerformSyncAuditing(invocation, auditInfo); } }
public void Intercept(IInvocation invocation) { try { invocation.Proceed(); if (AsyncHelper.IsAsyncMethod(invocation.Method)) { invocation.ReturnValue = ExtendedAsyncHelper.CallAwaitTaskWithFinallyAndGetResult( invocation.Method.ReturnType.GenericTypeArguments[0], invocation.ReturnValue, exception => HandleExceptionAsync(invocation, exception)); } } catch (ApiKeyNullException ex) { if (AsyncHelper.IsAsyncMethod(invocation.Method)) { HandleExceptionAsync(invocation, ex); } } catch (MaximumCharacterLimitException ex) { if (AsyncHelper.IsAsyncMethod(invocation.Method)) { HandleExceptionAsync(invocation, ex); } } catch (WebException ex) { if (AsyncHelper.IsAsyncMethod(invocation.Method)) { HandleExceptionAsync(invocation, ex); } } catch (Exception ex) { HandleException(invocation, ex); } }
public static BlockSyntax GetMethodBodyBlock(MethodInfo methodInfo, ServiceDescriptor serviceDescriptor) { var isAsyncMethod = AsyncHelper.IsAsyncMethod(methodInfo); return(SyntaxFactory.Block( CreateAssignmentStatement( $"var {RpcMessageInstanceVariableName}", $"new {nameof(RpcMessage)}()"), CreateAssignmentStatement( $"{RpcMessageInstanceVariableName}.{nameof(RpcMessage.ServiceCode)}", serviceDescriptor.ServiceCode.ToString()), CreateAssignmentStatement( $"{RpcMessageInstanceVariableName}.{nameof(RpcMessage.OperationCode)}", serviceDescriptor.GetOperationCodeByMethodInfo(methodInfo).ToString()), CreateAssignmentStatement( $"{RpcMessageInstanceVariableName}.{nameof(RpcMessage.IsAsyncOperation)}", isAsyncMethod.ToString().ToLower()), CreateAssignmentStatement( $"{RpcMessageInstanceVariableName}.{nameof(RpcMessage.ArgumentsData)}", $"{GetParametersSerializationCode(methodInfo.GetParameters().Select(parameterInfo => new MethodParameter(parameterInfo)).ToArray())}"), SyntaxFactory.ParseStatement(GetRemoteCallCode(methodInfo, isAsyncMethod)))); }
public void Intercept(IInvocation invocation) { var authorizeAttrList = ReflectionHelper.GetAttributesOfMemberAndDeclaringType <AbpAuthorizeAttribute>( invocation.MethodInvocationTarget ); if (authorizeAttrList.Count <= 0) { //No AbpAuthorizeAttribute to be checked invocation.Proceed(); return; } if (AsyncHelper.IsAsyncMethod(invocation.Method)) { InterceptAsync(invocation, authorizeAttrList); } else { InterceptSync(invocation, authorizeAttrList); } }
private static SyntaxToken[] GetModifiers(MethodInfo methodInfo) => AsyncHelper.IsAsyncMethod(methodInfo) ? new [] { SyntaxFactory.Token(SyntaxKind.PublicKeyword), SyntaxFactory.Token(SyntaxKind.AsyncKeyword) } : new [] { SyntaxFactory.Token(SyntaxKind.PublicKeyword) };