Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 4
0
 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));
 }
Ejemplo n.º 5
0
        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));
        }
Ejemplo n.º 6
0
        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));
        }
Ejemplo n.º 7
0
 public AdviceAttribute(AdviceExecution execution)
 {
     _execution = execution;
 }