コード例 #1
0
        public void Intercept(IInvocation invocation)
        {
            if (invocation.Method.IsAbstract)
            {
                _cachedGeneration.SetupReturnValueFor(invocation, _instanceSource, _trace);
            }
            else if (invocation.Method.IsVirtual)
            {
                try
                {
                    var previousReturnValue = invocation.ReturnValue;

                    invocation.Proceed();

                    if (invocation.ReturnValue == previousReturnValue)
                    {
                        _cachedGeneration.SetupReturnValueFor(invocation, _instanceSource, _trace);
                    }
                }
                catch (Exception)
                {
                    _cachedGeneration.SetupReturnValueFor(invocation, _instanceSource, _trace);
                }
            }
        }
コード例 #2
0
    public void Intercept(IInvocation invocation)
    {
        NSubstituteHacks.AssertIsNotInvokedDuringNSubstituteQuery(invocation, _instanceSource);

        if (invocation.Method.IsAbstract)
        {
            _cachedGeneration.SetupReturnValueFor(invocation, _instanceSource, _request);
        }
        else if (invocation.Method.IsVirtual)
        {
            try
            {
                var previousReturnValue = invocation.ReturnValue;

                invocation.Proceed();

                if (invocation.ReturnValue == previousReturnValue)
                {
                    _cachedGeneration.SetupReturnValueFor(invocation, _instanceSource, _request);
                }
            }
            catch (Exception)
            {
                _cachedGeneration.SetupReturnValueFor(invocation, _instanceSource, _request);
            }
        }
    }
コード例 #3
0
 public void Intercept(IInvocation invocation)
 {
     _cachedGeneration.SetupReturnValueFor(invocation, _instanceSource, _trace);
 }
コード例 #4
0
 public void Intercept(IInvocation invocation)
 {
     NSubstituteHacks.AssertIsNotInvokedDuringNSubstituteQuery(invocation, _instanceSource);
     _cachedGeneration.SetupReturnValueFor(invocation, _instanceSource, _request);
 }