public object Invoke(IInvocationInfo invocationInfo) { if (session.InTransaction) { return invocationInfo.Proceed(); } using (var transaction = session.Connection.BeginTransaction()) { session.InTransaction = true; try { var result = invocationInfo.Proceed(); transaction.Commit(); return result; } catch (Exception) { transaction.Rollback(); throw; } finally { session.InTransaction = false; } } }
public object Invoke(IInvocationInfo invocationInfo) { if (Context.IsActionIgnored()) { return(""); } if (!Context.Drivers.Any()) { return(invocationInfo.Proceed()); } var coreConfiguration = Context .ConfigurationProvider .Get(CoreConfiguration.Default); object lastResult = null; foreach (var driver in Context.Drivers) { Context.SetBrowser(driver); lastResult = invocationInfo.Proceed(); Context .Driver .WaitForDocumentCompleteness(coreConfiguration.WaitForDocumentCompleteState); } return(lastResult); }
public object Invoke(IInvocationInfo invocation) { var method = invocation.Proxy.Target.GetType().GetMethod(invocation.Method.Name); var joinPoint = new JoinPoint { Arguments = invocation.Arguments, MethodInfo = method, ReturnValue = null, TargetObject = invocation.Proxy.Target, TargetType = invocation.Proxy.Target.GetType(), ExecuteMethodFromProxy = (() => { var value = invocation.Proceed(); return value; }), }; var typesToApply = _types.Where(x => _pointCut.CanApply(joinPoint, x)).ToArray(); if (typesToApply.Length > 0) { var aspectsToApply = typesToApply.Select(x => _container.GetInstance(x) as IAspect).ToArray(); aspectsToApply = aspectsToApply.OrderBy(x => x.GetOrder(joinPoint)).ToArray(); var root = aspectsToApply[0]; var aspect = root; for (var i = 1; i < aspectsToApply.Length; i++) { aspect.NextAspect = aspectsToApply[i]; aspect = aspect.NextAspect; } root.Apply(joinPoint); return joinPoint.ReturnValue; } else { return invocation.Proceed(); } }
public object Invoke(IInvocationInfo invocationInfo) { if (invocationInfo.Method.CustomAttributes.ToList().Exists(e => e.AttributeType == typeof(TransactionAttribut))) { object proceedResult = null; ExecuteByTransection(() => { proceedResult = invocationInfo.Proceed(); }); return proceedResult; } return invocationInfo.Proceed(); }
public object Invoke(IInvocationInfo invocationInfo) { var args = string.Join(", ", invocationInfo.Arguments.Select(x => (x ?? string.Empty).ToString())); Debug.WriteLine("LightInject: {0}({1})", invocationInfo.Method, args); return(invocationInfo.Proceed()); }
/// <summary> /// Wraps the execution of a service operation inside a <see cref="Scope"/>. /// </summary> /// <param name="invocationInfo">The <see cref="IInvocationInfo"/> instance that /// contains information about the current method call.</param> /// <returns>The return value from the method.</returns> public object Invoke(IInvocationInfo invocationInfo) { using (serviceContainer.BeginScope()) { return(invocationInfo.Proceed()); } }
public object Invoke(IInvocationInfo invocationInfo) { using (_methodIdentityProvider.BeginNextMethodIdentityScope(_mehodIdentityKey)) { return(invocationInfo.Proceed()); } }
public object Invoke(IInvocationInfo invocationInfo) { // BEFORE the target method execution var methodInput = CreateMethodInput(invocationInfo); var(msgInputLog, correlationState) = _methodLogMessageFactory.CreateInputMethodLogMessage(methodInput); _logger.Info(msgInputLog); try { // Yield to the next module in the pipeline var returnValue = invocationInfo.Proceed(); // AFTER the target method execution var msgOutputLog = _methodLogMessageFactory.CreateOutputMethodLogMessage(new MethodReturn { ReturnValue = returnValue }, correlationState); _logger.Info(msgOutputLog); return(returnValue); } catch (Exception exp) { var msgOutputLog = _methodLogMessageFactory.CreateOutputMethodLogMessage(new MethodReturn { Exception = exp }, correlationState); _logger.Error(msgOutputLog); throw; } }
public object Invoke(IInvocationInfo invocationInfo) { var returnValue = invocationInfo.Proceed(); var globalCache = _globalCacheFactory.Invoke(); globalCache.NotifyRefresh((ICacheable)invocationInfo.Proxy); return(returnValue); }
public object Invoke(IInvocationInfo invocationInfo) { _logger.Log($"I'm calling method \"{invocationInfo.Method.Name}\"."); var returnValue = invocationInfo.Proceed(); _logger.Log($"Method \"{invocationInfo.Method.Name}\" finished successfully."); return(returnValue); }
public object Invoke(IInvocationInfo invocationInfo) { if (configuration.DelayerTime.TotalMilliseconds > 0) { Task.Delay((int)configuration.DelayerTime.TotalMilliseconds).Wait(); } return(invocationInfo.Proceed()); }
public object Invoke(IInvocationInfo invocationInfo) { Log.Debug($"Invoking {invocationInfo.Method.Name} with args " + $"{string.Join(",", invocationInfo.Arguments.First() as string[])}"); var response = invocationInfo.Proceed(); Log.Debug($"Invocation returned {response}"); return(response); }
public object Invoke(IInvocationInfo invocationInfo) { try { return(invocationInfo.Proceed()); } catch (TargetInvocationException ex) { throw ex.InnerException; } }
public object Invoke(IInvocationInfo invocationInfo) { var typeName = invocationInfo.Method.GetGenericArgumentsName().First(); var userFriendlyName = typeName.Split('.').Last(); if (Kernel.CanGet <IAction>(typeName) || Kernel.CanGet <IWorkflowAction>(typeName)) { Interpolate(ref invocationInfo); } return(invocationInfo.Proceed()); }
public object Invoke(IInvocationInfo invocationInfo) { //If there is a running transaction, just run the method if (NhUnitOfWork.Current != null) { return invocationInfo.Proceed(); } object returnValue; try { NhUnitOfWork.Current = new NhUnitOfWork(sessionFactory); NhUnitOfWork.Current.BeginTransaction(); try { returnValue = invocationInfo.Proceed(); NhUnitOfWork.Current.Commit(); } catch (Exception) { try { NhUnitOfWork.Current.Rollback(); } catch (Exception) { } throw; } } finally { NhUnitOfWork.Current = null; } return returnValue; }
public object Invoke(IInvocationInfo invocationInfo) { //If there is a running transaction, just run the method if (NhUnitOfWork.Current != null) { return(invocationInfo.Proceed()); } object returnValue; try { NhUnitOfWork.Current = new NhUnitOfWork(sessionFactory); NhUnitOfWork.Current.BeginTransaction(); try { returnValue = invocationInfo.Proceed(); NhUnitOfWork.Current.Commit(); } catch (Exception) { try { NhUnitOfWork.Current.Rollback(); } catch (Exception) { } throw; } } finally { NhUnitOfWork.Current = null; } return(returnValue); }
public object Invoke(IInvocationInfo invocationInfo) { try { // Perform logic before invoking the target method var returnValue = invocationInfo.Proceed(); // Perform logic after invoking the target method return returnValue; } catch (Exception ex) { LogExceptionInformation(invocationInfo, ex); throw; } }
public object Invoke(IInvocationInfo invocationInfo) { var retryableAttribute = invocationInfo.TargetMethod.GetCustomAttributes(typeof(RetryableAttribute), true).FirstOrDefault() as RetryableAttribute; if (retryableAttribute != null) { var policy = Policy .Handle <Exception>(handledException => retryableAttribute.Vlaue.Exists(exceptionType => handledException.GetType() == exceptionType)) .Retry(retryableAttribute.MaxAttempts, (exception, retryCount, context) => { Thread.Sleep(retryableAttribute.Delay * int.Parse(Math.Pow(retryableAttribute.Multiplier, retryCount - 1).ToString())); }); object proceedResult = null; policy.Execute(() => proceedResult = invocationInfo.Proceed()); return(proceedResult); } return(invocationInfo.Proceed()); }
public object Invoke(IInvocationInfo invocationInfo) { foreach (var argument in invocationInfo.Arguments) { Type argumentType = argument.GetType(); Type validatorType = typeof(AbstractValidator <>).MakeGenericType(argumentType); var validator = factory.TryGetInstance(validatorType); if (validator != null) { var validateMethod = validatorType.GetMethod("Validate", new Type[] { argumentType }); var result = (ValidationResult)validateMethod.Invoke(validator, new object[] { argument }); if (!result.IsValid) { //Throw an exception, log or any other action } } } //if ok, proceed to the actual service. return(invocationInfo.Proceed()); }
public object Invoke(IInvocationInfo invocationInfo) { var logger = EnrichLogger(invocationInfo); var stopwatch = new Stopwatch(); try { stopwatch.Start(); var result = invocationInfo.Proceed(); stopwatch.Stop(); logger.Information(LogMessageTemplates.SuccessMessage, stopwatch.ElapsedMilliseconds); return(result); } catch (Exception e) { stopwatch.Stop(); logger.Error(e, LogMessageTemplates.ExceptionMessage, stopwatch.ElapsedMilliseconds); throw; } }
public static void Process(this IInvocationInfo invocation, object?proxy = default) { var invocationTarget = invocation.Target; var proxyMember = ProxyMemberMappings.GetOrAdd(invocationTarget.GetType(), GetProxyMember); if (proxyMember != null && proxyMember.GetValue(invocationTarget) == null) { proxyMember.SetValue(invocationTarget, proxy); } var advice = AdviceMappings.GetOrAdd(invocation.Method, GetFirstOrDefaultAdvice); if (advice == null) { invocation.Proceed(); } else { advice.Apply(invocation); } }
private Task Invoke(IInvocationInfo invocation) { var method = invocation.Method; var wrapperCreator = GetWrapperCreator(method.ReturnType); var taskBlockingCollection = new BlockingCollection <Task>(); var wrapperTask = wrapperCreator(invocation, taskBlockingCollection); var returnValue = invocation.Proceed(); if (returnValue != null) { var returnTask = (Task)returnValue; taskBlockingCollection.Add(returnTask); } return(wrapperTask); }
/// <summary> /// Proceeds with an invocation. /// </summary> /// <param name="invocation">The invocation.</param> protected virtual void Proceed(IInvocationInfo invocation) { try { if (this.Next == null) { var result = invocation.Proceed(); invocation.ReturnValue = result; } else { this.Next.Apply(invocation); } } catch (Exception ex) { invocation.Exception = ex; if (!this.SwallowExceptions) { throw; } } }
/// <summary> /// Invoked when a method call is intercepted. /// </summary> /// <param name="invocationInfo">The <see cref="IInvocationInfo"/> instance that /// contains information about the current method call.</param> /// <returns>The return value from the method.</returns> public object Invoke(IInvocationInfo invocationInfo) { serviceContainer.EndCurrentScope(); return invocationInfo.Proceed(); }
public object Invoke(IInvocationInfo invocationInfo) { return(invocationInfo.Proceed()); }
public object Invoke(IInvocationInfo invocationInfo) { var args = string.Join(", ", invocationInfo.Arguments.Select(x => (x ?? string.Empty).ToString())); Debug.WriteLine("LightInject: {0}({1})", invocationInfo.Method, args); return invocationInfo.Proceed(); }
public object Invoke(IInvocationInfo invocationInfo) { Bar.ToString(); return invocationInfo.Proceed(); }
/// <summary> /// Invoked when a method call is intercepted. /// </summary> /// <param name="invocationInfo">The <see cref="IInvocationInfo"/> instance that /// contains information about the current method call.</param> /// <returns>The return value from the method.</returns> public object Invoke(IInvocationInfo invocationInfo) { serviceContainer.EndCurrentScope(); return(invocationInfo.Proceed()); }
public object Invoke(IInvocationInfo invocationInfo) { return invocationInfo.Proceed(); }
public object Invoke(IInvocationInfo invocationInfo) { Bar.ToString(); return(invocationInfo.Proceed()); }