using System;
using System.Collections.Generic;
using System.Linq;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.Entities;
using Umbraco.Extensions;
namespace Umbraco.Cms.Core.Cache
{
///
/// Implements by wrapping an inner other
/// instance, and ensuring that all inserts and returns are deep cloned copies of the cache item,
/// when the item is deep-cloneable.
///
public class DeepCloneAppCache : IAppPolicyCache, IDisposable
{
private bool _disposedValue;
///
/// Initializes a new instance of the class.
///
public DeepCloneAppCache(IAppPolicyCache innerCache)
{
var type = typeof (DeepCloneAppCache);
if (innerCache.GetType() == type)
throw new InvalidOperationException($"A {type} cannot wrap another instance of itself.");
InnerCache = innerCache;
}
///
/// Gets the inner cache.
///
private IAppPolicyCache InnerCache { get; }
///
public object Get(string key)
{
var item = InnerCache.Get(key);
return CheckCloneableAndTracksChanges(item);
}
///
public object Get(string key, Func