Enterprise Library: Configuration Application Block

來源:互聯網
上載者:User

ConfigurationBuilder類用來返回儲存區中當前配置設定。基於效能的考慮,當每一個配置節資訊從儲存區讀取後,ConfigurationBuilder將緩衝該配置資訊。只要緩衝資訊與底層儲存區資料保持一致,緩衝資訊將返回給應用程式。當Storage Provider檢測到配置設定發生變化時,它將觸發一個事件,表示該配置節發生了變化。當ConfigurationBuilder接受到該事件時,將從緩衝中清除該配置節資訊。這樣,在應用程式下次嘗試讀取該節配置資訊時,ConfigurationBuilder將從儲存區直接讀取新的配置資訊。

當使用XML檔案的Storage Provider時,從設定檔發生改變到檢測到該改變大約存在1500毫秒的延遲。ConfigurationChangeFileWatcher對象每1500毫秒輪詢XML設定檔的變化,這不是一個可配置的設定。不過,你可以通過修改ConfigurationChangeFileWatcher原始碼來改變輪詢的頻率。

另外,Client端程式也可以通過調用ConfigurationManager.ClearSingletonCache方法來清除緩衝。

Code Snippet如下所示:

private void btnClearCache_Click(object sender, System.EventArgs e)

{

// Removes all sections from the internal cache.

ConfigurationManager.ClearSingletonSectionCache();

txtConfigurationData.Text += "The cache of configuration data has been cleared." + Environment.NewLine;

}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.