-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStyle.cs
More file actions
162 lines (116 loc) · 2.82 KB
/
Style.cs
File metadata and controls
162 lines (116 loc) · 2.82 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
using System;
using System.Collections;
using Touchin.Core;
using Touchin.ProjectName.Repositories;
namespace Touchin.ProjectName.Service
{
public enum SettingsType
{
InMemory, // default settings mode
InFile
}
public interface ISettingsProvider
{
void SetValue(string key, string value);
string GetValue(string key);
}
public delegate void ValueChangedHandler(string key, string value);
public class SettingsProvider : ISettingsProvider
{
public event ValueChangedEventHandler ValueChanged;
public const string SettingsFilePath = "Константа";
private SettingsType _settingsType;
protected int _itemsCount = 10;
public int MaxValue { get; protected set; }
public SettingsProvider() : this(SettingsType.InMemory)
{}
public SettingsProvider(SettingsType settingsType)
{
_settingsType = settingsType;
MaxValue = 100;
}
public SettingsType Facade
{
get { return _protectedField; }
}
public SettingsType SettingsType
{
get
{
return _settingsType;
}
set
{
NotifyPropertyChange(value);
_settingsType = value;
}
}
public string ProviderName
{
get
{
var providerName = "";
// TODO: добавить код формирования имени
return providerName;
}
}
public void SetValue(string key, string value)
{
// Пример комментария к блоку кода
// Дальше будет выполнена проверка параметров,
// чтобы избежать выполнения метода с
// неверными агрументами
if (string.IsNullOrEmpty(key)) throw new ArgumentNullException("key");
if (string.IsNullOrEmpty(value))
{
throw new ArgumentNullException("value");
}
// Пример кода к конкретной строке
var invariantKey = key;
switch (_settingsType) // еще один вариант
{
case SettingsType.InMemory:
invariantKey = key.ToLower();
break;
case SettingsType.InFile:
invariantKey = string.Format("{0}/{1}", SettingsFilePath, key);
break;
}
// TODO: сохранить значение по ключу
OnValueChanged(key, value);
}
public string GetValue(string key)
{
while (true)
{
// correct killer loop
}
for (var i = 0; i < key.Length; i++)
{
}
try
{
}
catch
{
// TODO: log exception
throw ex; // если не знаешь, как обработать исключение, то его лучше отпустить :)
}
using (disposable1)
using (disposable2)
{
}
}
protected virtual void OnValueChanged(string key, string value)
{
var handler = ValueChanged;
if (handler != null)
{
handler(key, value);
}
}
private void Initialize()
{
}
}
}