public static Advice GetAdvice(MethodInfo method = null, AdviceExecution execution = (AdviceExecution)0, Aspect aspect = null, ICrosscutting crosscutting = null) { method = method ?? GetMethodInfo(returnType: typeof(void), parameterTypes: Type.EmptyTypes); crosscutting = crosscutting ?? GetCrosscutting(); aspect = aspect ?? GetAspect(); return(new Advice(aspect, method, execution, crosscutting)); }
private Expression CreateBlock(IEnumerable <WeaveTimeAdvice> advices, AdviceExecution execution, ParameterExpression context) { var calls = advices .Where(x => x.Advice.Execution == execution) .Select(x => _adviceCallExpressionBuilder.CreateExpression(x, context)) .Cast <Expression>().ToList(); return(calls.Any() ? Expression.Block(calls) : null); }
public Advice( Aspect aspect, MethodInfo method, AdviceExecution execution, ICrosscutting crosscutting) : base(aspect) { ArgumentUtility.CheckNotNull("method", method); ArgumentUtility.CheckNotNull("aspect", aspect); ArgumentUtility.CheckNotNull("crosscutting", crosscutting); _method = method; _execution = execution; _crosscutting = crosscutting; }
public static IAdviceBuilder GetAdviceBuilder( IAspectConstruction construction = null, MethodInfo method = null, AdviceExecution execution = AdviceExecution.Before, AdviceScope scope = AdviceScope.Instance) { construction = construction ?? GetConstruction(); method = method ?? GetMethodInfo(); return(new AdviceBuilder() .SetConstruction(construction) .SetMethod(method) .SetExecution(execution) .SetScope(scope)); }
private void CheckThrowForMissing( string missingMember, IAspectConstruction construction = null, MethodInfo method = null, AdviceExecution execution = AdviceExecution.Undefined, AdviceScope scope = AdviceScope.Undefined) { var builder = new AdviceBuilder() .SetConstruction(construction) .SetMethod(method) .SetExecution(execution) .SetScope(scope); var message = string.Format("Cannot build advice without having set its {0}.", missingMember); Assert.That(() => builder.Build(), Throws.InvalidOperationException.With.Message.EqualTo(message)); }
public static Advice GetAdvice( IAspectConstruction construction = null, MethodInfo method = null, string role = null, string name = null, AdviceExecution execution = AdviceExecution.Around, AdviceScope scope = AdviceScope.Static, int priority = 0, IEnumerable <IPointcut> pointcuts = null) { construction = construction ?? GetConstruction(); method = method ?? GetMethodInfo(); name = name ?? "name"; role = role ?? "role"; pointcuts = pointcuts ?? new IPointcut[0]; return(new Advice(construction, method, name, role, execution, scope, priority, pointcuts)); }
public AdviceAttribute(AdviceExecution execution) { _execution = execution; }