Aspectacular.Aspect.CancelInterceptedMethodCallAndSetReturnValue C# (CSharp) Method

CancelInterceptedMethodCallAndSetReturnValue() protected method

This method can be used by caching aspects to supply return value without calling method itself.
protected CancelInterceptedMethodCallAndSetReturnValue ( object newReturnValue ) : void
newReturnValue object
return void
        protected void CancelInterceptedMethodCallAndSetReturnValue(object newReturnValue)
        {
            if(this.Proxy.MethodWasCalled)
                throw new Exception("Invalid attempt to cancel intercepted method call after it was called.");

            this.Proxy.ReturnedValue = newReturnValue;
            this.Proxy.CancelInterceptedMethodCall = true;
        }