Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Configuration;
- namespace settingstest
- {
- class Program
- {
- static void Main(string[] args)
- {
- MySettings s = new MySettings();
- Console.WriteLine(s.StringValue1);
- showItems("before", s);
- int numItems = s.Items.Count;
- s.Items.Add(string.Format("item{0}", numItems));
- s.StringValue1 = "init";
- s.Save();
- showItems("after", s);
- }
- private static void showItems(string title, MySettings s)
- {
- Console.WriteLine(title);
- foreach (string str in s.Items)
- {
- Console.WriteLine("Item: {0}", str);
- }
- }
- }
- class MySettings : ApplicationSettingsBase
- {
- public MySettings()
- : base()
- {
- if (Items == null)
- Items = new List<string>();
- }
- [UserScopedSetting()]
- public string StringValue1 { get; set; }
- [UserScopedSetting()]
- [SettingsSerializeAs(SettingsSerializeAs.Xml)]
- public List<string> Items
- {
- get { return (List<string>)this["Items"]; }
- set { this["Items"] = value; }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement