示例#1
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);
        }
    }
示例#2
0
    public void GenerateAndAddPropertyGetterReturnValueTo(PerMethodCache <object> perMethodCache)
    {
        var key = GetPropertyGetterCacheKey();

        perMethodCache.Overwrite(key, _invocation.Arguments[0]);
    }
 public CachedReturnValueGeneration(PerMethodCache <object> cache)
 {
     _cache = cache;
 }