Silverlight獨立存儲配置相關操作步驟講解
Silverlight開發工具中有很多功能可以被我們靈活的利用創造出更多的新穎的功能服務于大眾。對于這樣的一款多媒體處理工具,其功能是非常強大的。Silverlight獨立存儲配置,在Beta 1時代是應用程序配置,現在不僅支持應用程序配置,同時還支持站點配置,我們可以用它來存儲應用程序配置如每個頁面顯示的圖片數量,頁面布局自定義配置等等,使用IsolatedStorageSettings類來實現,該類在設計時使用了字典來存儲名-值對,它的使用相當簡單:#t#
- IsolatedStorageSettings appSettings =
IsolatedStorageSettings.ApplicationSettings; - appSettings.Add("mykey","myValue");
- appSettings.Save();
- IsolatedStorageSettings siteSettings =
- IsolatedStorageSettings.SiteSettings;
- siteSettings.Add("mykey1","myValue1");
- siteSettings.Save();
Silverlight獨立存儲配置的機制也是基于本地文件存儲,系統默認的會創建一個名為__LocalSettings的文件進行存儲。
打開文件后可以看到,存儲的內容(此處進行了整理)
- < ArrayOfKeyValueOfstringanyType
- xmlns:i="http://www.w3.org/2001
/XMLSchema-instance"- xmlns="http://schemas.microsoft
.com/2003/10/Serialization/Arrays">- < KeyValueOfstringanyType>
- < Key>mykey< /Key>
- < Value xmlns:d3p1="http://
www.w3.org/2001/XMLSchema"- i:type="d3p1:string">myValue< /Value>
- < /KeyValueOfstringanyType>
- < /ArrayOfKeyValueOfstringanyType>
值得一提的是使用Silverlight獨立存儲配置不僅僅可以存儲簡單類型的數據,也可以存儲我們自定義類型的數據。