Example #1
0
    private PerMethodCacheKey GetPropertyGetterCacheKey()
    {
        var propertyFromSetterCallOrNull =
            _invocation.Method.GetPropertyFromSetterCall();
        var getter = propertyFromSetterCallOrNull.GetGetMethod(true);
        var key    = PerMethodCacheKey.For(getter, _invocation.Proxy);

        return(key);
    }
Example #2
0
    public void GenerateAndAddMethodReturnValueTo(PerMethodCache <object> perMethodCache, GenerationRequest request)
    {
        var cacheKey = PerMethodCacheKey.For(_invocation);

        if (!perMethodCache.AlreadyContainsValueFor(cacheKey))
        {
            var returnValue = AnyInstanceOfReturnTypeOf(_invocation, request);
            perMethodCache.Add(cacheKey, returnValue);
            _invocation.ReturnValue = returnValue;
        }
        else
        {
            _invocation.ReturnValue = perMethodCache.ValueFor(cacheKey);
        }
    }