public static ICacheContext GetCacheObject(string profile, string name) { if (!classMaps.ContainsKey(name)) { throw new ArgumentNullException(String.Format("Cache name not found [{0}]", name)); } PluginEntry entry = classMaps[name]; Dictionary <string, ICacheContext> cacheMaps = null; if (!cacheProfileMaps.ContainsKey(profile)) { cacheMaps = new Dictionary <string, ICacheContext>(); cacheProfileMaps.Add(profile, cacheMaps); } else { cacheMaps = cacheProfileMaps[profile]; } ICacheContext cacheObj = null; if (!cacheMaps.ContainsKey(name)) { //Create just only one time and reuse it later //Using lazy approach Assembly asm = Assembly.Load(entry.Asm.GetName()); cacheObj = (ICacheContext)asm.CreateInstance(entry.Fqdn); cacheMaps.Add(name, cacheObj); if (loggerFactory != null) { Type t = cacheObj.GetType(); ILogger logger = loggerFactory.CreateLogger(t); cacheObj.SetLogger(logger); } } else { cacheObj = cacheMaps[name]; } return(cacheObj); }