-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathSettingsList.cs
More file actions
53 lines (41 loc) · 1.35 KB
/
Copy pathSettingsList.cs
File metadata and controls
53 lines (41 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SharpQuant.Common;
namespace SharpQuant.UI
{
/// <summary>
/// This class is used to pass information around UI objects (kind of a message)
/// </summary>
public class SettingsList: SettingsDictionary
{
static SettingsList()
{
_itemSeparator = ";";
_valueSeparator = "|";
}
public new static SettingsList Deserialize(string s)
{
SettingsList list = new SettingsList();
string[] items = s.Split(new string[] { _itemSeparator }, StringSplitOptions.None);
foreach (var item in items)
{
string[] entry = item.Split(new string[] { _valueSeparator }, StringSplitOptions.None);
if (entry.Length != 2) return list;
list.Add(entry[0], entry[1]);
}
return list;
}
public override string Serialize()
{
StringBuilder sb = new StringBuilder();
foreach (var item in this)
{
sb.Append(item.Key); sb.Append(_valueSeparator); sb.Append(item.Value); sb.Append(_itemSeparator);
}
if (sb.Length > 1) return sb.ToString(0, sb.Length - 1);
return string.Empty;
}
}
}