List <AdviceModel> ProcessAdvice() { var environment = new Environment(_pointcutDefinitions); IEnumerable <AdviceModel> CompileAdvice ( IEnumerable <PointcutExpression> definitions, Func <PointcutExpression, Func <MethodDefinition, bool>, AdviceModel> func ) => definitions .Select(d => { try { var compiledFunc = Compiler.Compile(d, environment); return(func(d, compiledFunc)); } catch (WeavingException e) { throw new WeavingException($"{e.Message}At {d.DefiningMethod.FullName}"); } }); var beforeResults = CompileAdvice(_beforeDefinitions, (expression, func) => new BeforeAdvice(expression.DefiningMethod, func)); var aroundResults = CompileAdvice(_aroundDefinitions, (expression, func) => new AroundAdvice(expression.DefiningMethod, func)); return(beforeResults.Concat(aroundResults) .ToList()); }
public Compiler(PointcutExpression expression, Environment environment) => (_expression, _environment) = (expression, environment);