/// <summary> /// Gets the config from the cache if it can, from the source otherwise. /// </summary> /// <typeparam name="T">The configuration type</typeparam> /// <typeparam name="Tm">The configuration metadata type</typeparam> /// <param name="configurationMetadata">The metadata related to the configuration, default gathered from Type Data</param> /// <returns>The configuration</returns> protected internal virtual T GetConfiguration <T, Tm>(Tm configurationMetadata = default(Tm)) where T : IConfiguration <T, Tm>, new() where Tm : IConfigurationMetadata <T, Tm>, new() { Tm metadata = GetMetadataForConfiguration <T, Tm>(configurationMetadata); ICachedObject <T> cachedObject = CachingService.Retrieve <T>(metadata.ConfigurationName); T configuration; if (cachedObject == null || cachedObject.ExpireTime < DateTime.UtcNow || cachedObject.Value == null) { configuration = GetConfigurationFromSource <T, Tm>(metadata); } else { configuration = cachedObject.Value; } return(configuration); }