switch classes depending on value
<p>I have two classes which share the identical methods and I would like to switch them in code depending on requirement. If you will look at example below you will find that the same portion of code is duplicated. The CacheFile and CacheMemory classes are identical, I am sure this code can be shrinked and CacheFile and CacheMemory classes can be switched.</p>

<pre><code>    if (_cacheLocation == CacheLocation.File)
    {
        if (!CacheFile.Get(key, out value))
        {
            // Do lookup based on caller's logic.   
            context.Proceed();
            value = context.ReturnValue;
            CacheFile.Add(value, key, _cacheType, _expiry);
        }
    }

    if (_cacheLocation == CacheLocation.Memory)
    {
        if (!CacheMemory.Get(key, out value))
        {
            // Do lookup based on caller's logic.   
            context.Proceed();
            value = context.ReturnValue;
            CacheMemory.Add(value, key, _cacheType, _expiry);
        }
    }
</code></pre>
