public void RegisterCache(string name, ISdkCache cache) { Guard.Argument(name, nameof(name)).NotNull().NotEmpty(); Guard.Argument(cache, nameof(cache)).NotNull(); if (_caches == null) { _caches = new Dictionary <string, ISdkCache>(); } if (cache.RegisteredDtoTypes == null || !cache.RegisteredDtoTypes.Any()) { throw new ArgumentException("Missing registered dto types", nameof(cache.RegisteredDtoTypes)); } if (_caches.ContainsKey(name)) { ExecLog.LogWarning($"Cache with the name={name} already added. Removing it."); _caches.Remove(name); } ExecLog.LogDebug($"Registering cache with the name={name} to the CacheManager."); _caches.Add(name, cache); }
/// <summary> /// Registers the cache in the CacheManager /// </summary> /// <param name="name">The name of the instance</param> /// <param name="cache">The cache to be registered</param> public void RegisterCache(string name, ISdkCache cache) { Contract.Requires(!string.IsNullOrEmpty(name)); Contract.Requires(cache != null); if (_caches == null) { _caches = new Dictionary <string, ISdkCache>(); } if (cache.RegisteredDtoTypes == null || !cache.RegisteredDtoTypes.Any()) { throw new ArgumentException("Missing registered dto types", nameof(cache.RegisteredDtoTypes)); } if (_caches.ContainsKey(name)) { //throw new ArgumentException("Cache with this name already added.", nameof(name)); ExecLog.Warn($"Cache with the name={name} already added. Removing it."); _caches.Remove(name); //return; } ExecLog.Debug($"Registering cache with the name={name} to the CacheManager."); _caches.Add(name, cache); }