public void Set_configrationSection_then_read() { var section1 = new CacheConfigurationSection { Pattern = "{region}/{key}", FormatNullRegion = true, MaxExpirationHour = 1D, Details = new CacheItemElementCollection() }; section1.Details.Add(new CacheItemDetailElement { Region = "someRegion", Pattern = "{region}//{key}", Provider = typeof(RedisCacheProvider).FullName, FormatNullRegion = false, }); var resolver = new ConfigurationResolver(); resolver.ExeConfigFilename = "test.config"; resolver.Save(section1, "cacheBuilder"); var section2 = resolver.Read <CacheConfigurationSection>("cacheBuilder"); Assert.AreEqual(section2.Pattern, section1.Pattern); Assert.AreEqual(section2.FormatNullRegion, section1.FormatNullRegion); Assert.AreEqual(section2.MaxExpirationHour, section1.MaxExpirationHour); Assert.IsNotNull(section2.Details); Assert.AreEqual(section2.Details.Count, section1.Details.Count); Assert.AreEqual( section2.Details.Get(typeof(RedisCacheProvider).FullName), section1.Details.Get(typeof(RedisCacheProvider).FullName) ); }
public WechatCustomApi(ICacheProvider cacheProvider) { _cacheProvider = cacheProvider; var root = HttpRuntime.AppDomainId == null ? AppDomain.CurrentDomain.BaseDirectory : HttpRuntime.AppDomainAppPath; var configurationResolver = new ConfigurationResolver(Path.Combine(root, "Storage.config")); _configSection = configurationResolver.Read<WechatConfigurationSection>("WechatMPConfigurationSection"); }