ConfigAppSettings.cs
1.5 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Threading;
using System.Xml;
using System.Windows.Forms;
using log4net;
namespace OnlineStore.Common
{
public class ConfigAppSettings
{
private static int seq = 1;
public static int nextSeq()
{
if (seq.Equals(Int32.MaxValue))
{
LogUtil.info("seq当前值:" + seq + ",重置seq=0");
seq = 0;
}
Interlocked.Increment(ref seq);
return seq;
}
public static T GetValue<T>(string key, T defaultVal =default(T),string comment="")
{
return getVal(key, defaultVal, comment);
}
static T getVal<T>(string key, T defaultVal = default(T),string comment="")
{
ConfigHelper.Config.SetComment(key, comment);
return ConfigHelper.Config.Get<T>(key, defaultVal);
}
public static int GetIntValue(string key,int defaultVal=0,string comment="")
{
return getVal(key, defaultVal,comment);
}
public static void SaveValue<T>(string key, T value, string comment = "")
{
ConfigHelper.Config.SetComment(key, comment);
ConfigHelper.Config.Set(key, value);
}
/// <summary>
/// 模拟
/// </summary>
public static bool simulationMode { get { return getVal(Setting_Init.simulationMode, true); } }
}
}