-
Notifications
You must be signed in to change notification settings - Fork 0
/
Configuration.cs
186 lines (172 loc) · 5.2 KB
/
Configuration.cs
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
namespace WebServiceStudio
{
using System;
using System.ComponentModel;
using System.IO;
using System.Reflection;
using System.Xml.Serialization;
[TypeConverter(typeof(ExpandableObjectConverter))]
public class Configuration
{
private CustomHandler[] dataEditors;
private InvokeProperties invokeSettings = new InvokeProperties();
private static Configuration masterConfig = null;
private CustomHandler[] proxyProperties;
private CustomHandler[] typeConverters;
private UiProperties uiSettings;
private WsdlProperties wsdlSettings;
public Configuration Copy()
{
MemoryStream stream = new MemoryStream();
XmlSerializer serializer = new XmlSerializer(typeof(Configuration));
serializer.Serialize((Stream) stream, masterConfig);
stream.Position = 0L;
return (serializer.Deserialize(stream) as Configuration);
}
private static string GetConfigFileName()
{
return (Assembly.GetExecutingAssembly().Location + ".options");
}
internal string[] GetProxyBaseTypes()
{
CustomHandler[] proxyProperties = this.ProxyProperties;
string[] strArray = new string[(proxyProperties != null) ? (proxyProperties.Length + 1) : 1];
strArray[0] = "";
for (int i = 1; i < strArray.Length; i++)
{
strArray[i] = proxyProperties[i - 1].TypeName;
}
return strArray;
}
public static void LoadMasterConfig()
{
try
{
FileStream stream = File.OpenRead(GetConfigFileName());
StreamReader textReader = new StreamReader(stream);
XmlSerializer serializer = new XmlSerializer(typeof(Configuration));
masterConfig = serializer.Deserialize(textReader) as Configuration;
stream.Flush();
stream.Close();
}
catch
{
}
if (masterConfig == null)
{
masterConfig = new Configuration();
}
if (masterConfig.DataEditors == null)
{
masterConfig.DataEditors = new CustomHandler[0];
}
if (masterConfig.TypeConverters == null)
{
masterConfig.TypeConverters = new CustomHandler[0];
}
if (masterConfig.WsdlSettings == null)
{
masterConfig.WsdlSettings = new WsdlProperties();
}
if (masterConfig.UiSettings == null)
{
masterConfig.UiSettings = new UiProperties();
}
}
public static void SaveMasterConfig()
{
FileStream stream = File.OpenWrite(GetConfigFileName());
StreamWriter writer = new StreamWriter(stream);
new XmlSerializer(typeof(Configuration)).Serialize((TextWriter) writer, masterConfig);
stream.SetLength(stream.Position);
stream.Flush();
stream.Close();
}
[Browsable(false)]
public CustomHandler[] DataEditors
{
get
{
return this.dataEditors;
}
set
{
this.dataEditors = value;
}
}
[Browsable(false)]
public InvokeProperties InvokeSettings
{
get
{
return this.invokeSettings;
}
set
{
this.invokeSettings = value;
}
}
internal static Configuration MasterConfig
{
get
{
if (masterConfig == null)
{
LoadMasterConfig();
}
return masterConfig;
}
set
{
masterConfig = value;
SaveMasterConfig();
}
}
[Browsable(false)]
public CustomHandler[] ProxyProperties
{
get
{
return this.proxyProperties;
}
set
{
this.proxyProperties = value;
}
}
[Browsable(false)]
public CustomHandler[] TypeConverters
{
get
{
return this.typeConverters;
}
set
{
this.typeConverters = value;
}
}
public UiProperties UiSettings
{
get
{
return this.uiSettings;
}
set
{
this.uiSettings = value;
}
}
public WsdlProperties WsdlSettings
{
get
{
return this.wsdlSettings;
}
set
{
this.wsdlSettings = value;
}
}
}
}