1

現在、CAB CacheManager を動作させるために app.config に大量の XML を含める必要があり、コード内で構成を隠したいと考えています。

Enterprise Library Caching Application Block の CacheManager をプログラムで構成する方法はありますか?

4

1 に答える 1

1

web.config で configSource 属性を使用して、CAB 構成を別の構成ファイルに移動しないのはなぜですか?

例えば:

<?xml version="1.0"?>
<configuration>
    <configSections>
        <section name="cachingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings, Microsoft.Practices.EnterpriseLibrary.Caching, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
         ....


</configSections>

 <cachingConfiguration configSource="Config\Caching.config" />

そして、Config\Caching.config で:

<?xml version="1.0" encoding="utf-8" ?>
<cachingConfiguration defaultCacheManager="DefaultCacheManager">
    <cacheManagers>
        <add name="DefaultCacheManager"
             expirationPollFrequencyInSeconds="60"
             maximumElementsInCacheBeforeScavenging="1000"
             numberToRemoveWhenScavenging="10"
             backingStoreName="Null Storage"
             type="Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager, Microsoft.Practices.EnterpriseLibrary.Caching, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

..

私の知る限り、web.config の configSection ごとに個別の構成ファイルを使用できます。

秒。

于 2010-06-10T10:17:30.603 に答える