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>()); }
/// <inheritdoc/> public ConditionalResult <T> Get <T>(string key) where T : class { CachedObject cachedObject = _cache.Get(key); if (cachedObject == null) { return(ConditionalResult.CreateFailure <T>()); } if (cachedObject.Value == null) { return(ConditionalResult.CreateSuccessful <T>(null)); } var castedValue = cachedObject.Value as T; if (castedValue == null) { return(ConditionalResult.CreateFailure <T>()); } return(ConditionalResult.CreateSuccessful(castedValue)); }