Beispiel #1
0
        public void Intercept(IInvocation invocation)
        {
            if (!invocation.Method.IsProperty())
            {
                invocation.Proceed();
                _postProcessor.PostProcessReturnValue(invocation);
                return;
            }

            var ctx = new PropertySelectionContext(invocation);

            var result = new InvocationSwitchboard
            {
                { () => SubstituteFor(ctx) != null, () => Assign(SubstituteFor(ctx)) },
                { () => !ctx.Attributes.Any() && !ctx.IsPageComponent, () => Proceed },
                { () => ctx.IsPageComponent, () => Assign(ProxyFor(ctx.TargetProperty)) },
                { () => ElementFor(ctx) != null, () => Assign(ElementFor(ctx)) }
            }.Route();

            EnsureAnyElementsAreSafelyLoaded(ctx);

            invocation.Assign(result);
            invocation.ReturnValue = _postProcessor.PostProcessReturnValue(invocation.ReturnValue, ctx, _configuration);
        }