root/lang/csharp/MTFileUploader/MTFileUploader/Settings.cs

Revision 11244, 2.5 kB (checked in by mayuki, 8 months ago)

アップグレード元がないと死ぬのを修正。

  • Property svn:keywords set to Id
Line 
1using System.Configuration;
2using System;
3namespace MTFileUploader.Properties {
4   
5   
6    // This class allows you to handle specific events on the settings class:
7    //  The SettingChanging event is raised before a setting's value is changed.
8    //  The PropertyChanged event is raised after a setting's value is changed.
9    //  The SettingsLoaded event is raised after the setting values are loaded.
10    //  The SettingsSaving event is raised before the setting values are saved.
11    internal sealed partial class Settings {
12       
13        public Settings() {
14            // // To add event handlers for saving and changing settings, uncomment the lines below:
15            //
16            // this.SettingChanging += this.SettingChangingEventHandler;
17            //
18            // this.SettingsSaving += this.SettingsSavingEventHandler;
19            //
20            this.SettingsLoaded += (sender, e) =>
21            {
22                if (Sites == null)
23                {
24                    Sites = new SiteSettingCollection();
25                    Upgrade();
26                }
27            };
28        }
29
30        public override void Upgrade()
31        {
32            // 1.0.0.0 からアップグレード
33            if (!String.IsNullOrEmpty(GetPreviousVersion("UserName") as String))
34            {
35                SiteSetting setting = new SiteSetting
36                {
37                    SettingName = System.String.Format("{0} ({1})", GetPreviousVersion("EndPointUrl"), GetPreviousVersion("UserName")),
38                    UserName = GetPreviousVersion("UserName") as string,
39                    Password = GetPreviousVersion("Password") as string,
40                    HttpUserName = GetPreviousVersion("HttpUserName") as string,
41                    HttpPassword = GetPreviousVersion("HttpPassword") as string,
42                    BlogId = (System.Int32)GetPreviousVersion("BlogId"),
43                    EndPointUrl = GetPreviousVersion("EndPointUrl") as string
44                };
45                Sites.Add(setting);
46                Save();
47            }
48        }
49   
50        private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) {
51            // Add code to handle the SettingChangingEvent event here.
52        }
53       
54        private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) {
55            // Add code to handle the SettingsSaving event here.
56        }
57    }
58}
Note: See TracBrowser for help on using the browser.