コード例 #1
0
        // Load method, can be called without create new Setting.
        public static Setting Load()
        {
            Setting setting;
            using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
            {
                // Check if we have exiting settings.
                if (storage.FileExists(filename))
                {
                    IsolatedStorageFileStream stream = storage.OpenFile(filename, FileMode.OpenOrCreate);
                    XmlSerializer xml = new XmlSerializer(typeof(Setting));
                    //setting = xml.Deserialize(stream) as Setting;

                    try
                    {
                        setting = xml.Deserialize(stream) as Setting;
                    }
                    catch
                    {
                        setting = new Setting();
                    }

                    stream.Close();
                    stream.Dispose();
                }
                // If not we will restore to default setting.
                else
                {
                    setting = new Setting();
                }
            }
            return setting;
        }
コード例 #2
0
 // Code to execute when the application is launching (eg, from Start)
 // This code will not execute when the application is reactivated
 private void Application_Launching(object sender, LaunchingEventArgs e)
 {
     CurrentSetting = Setting.Load();
 }