I\'ve got a class that needs to store data in a cache. Originally I used it in an asp.net application so I used System.Web.Caching.Cache.
Now I need to use it in a Windo
I would go with your second option and refactor things a little bit. I would create an Interface and two Providers (which are your adapters):
public interface ICachingProvider
{
void AddItem(string key, object value);
object GetItem(string key);
}
public AspNetCacheProvider : ICachingProvider
{
// Adapt System.web.Caching.Cache to match Interface
}
public MemoryCacheProvider : ICachingProvider
{
// Adapt System.Runtime.Caching.MemoryCache to match Interface
}