Ejemplo n.º 1
0
        public ConditionalResult <T> Get <T>(string key)
            where T : class
        {
            var cachedObject = _cache.Get(key);

            if (cachedObject?.Value != null)
            {
                if (_cloningProvider.RequireCloning(cachedObject.Value.GetType()))
                {
                    return(ConditionalResult.CreateSuccessful(_cloningProvider.Clone(cachedObject.Value as T)));
                }

                return(ConditionalResult.CreateSuccessful(cachedObject.Value as T));
            }

            return(ConditionalResult.CreateFailure <T>());
        }
Ejemplo n.º 2
0
 public void NoCloningProviderShouldThrowWhenCloning()
 {
     Assert.Throws <NotImplementedException>(() => _noCloningProvider.Clone(new object()));
 }