- code refactoring
[reactos.git] / irc / TechBot / TechBot.Console / Main.cs
1 using System;
2 using System.Configuration;
3 using TechBot.Library;
4
5 namespace TechBot.Console
6 {
7 class MainClass
8 {
9 private static void VerifyRequiredOption(string optionName,
10 string optionValue)
11 {
12 if (optionValue == null)
13 {
14 throw new Exception(String.Format("Option '{0}' not set.",
15 optionName));
16 }
17 }
18
19 private static string IRCServerHostName
20 {
21 get
22 {
23 string optionName = "IRCServerHostName";
24 string s = ConfigurationSettings.AppSettings[optionName];
25 VerifyRequiredOption(optionName,
26 s);
27 return s;
28 }
29 }
30
31 private static int IRCServerHostPort
32 {
33 get
34 {
35 string optionName = "IRCServerHostPort";
36 string s = ConfigurationSettings.AppSettings[optionName];
37 VerifyRequiredOption(optionName,
38 s);
39 return Int32.Parse(s);
40 }
41 }
42
43 private static string IRCChannelNames
44 {
45 get
46 {
47 string optionName = "IRCChannelNames";
48 string s = ConfigurationSettings.AppSettings[optionName];
49 VerifyRequiredOption(optionName,
50 s);
51 return s;
52 }
53 }
54
55 private static string IRCBotName
56 {
57 get
58 {
59 string optionName = "IRCBotName";
60 string s = ConfigurationSettings.AppSettings[optionName];
61 VerifyRequiredOption(optionName,
62 s);
63 return s;
64 }
65 }
66
67 private static string IRCBotPassword
68 {
69 get
70 {
71 string optionName = "IRCBotPassword";
72 string s = ConfigurationSettings.AppSettings[optionName];
73 VerifyRequiredOption(optionName,
74 s);
75 return s;
76 }
77 }
78
79 private static string ChmPath
80 {
81 get
82 {
83 string optionName = "ChmPath";
84 string s = ConfigurationSettings.AppSettings[optionName];
85 VerifyRequiredOption(optionName,
86 s);
87 return s;
88 }
89 }
90
91 private static string MainChm
92 {
93 get
94 {
95 string optionName = "MainChm";
96 string s = ConfigurationSettings.AppSettings[optionName];
97 VerifyRequiredOption(optionName,
98 s);
99 return s;
100 }
101 }
102
103 private static string NtstatusXml
104 {
105 get
106 {
107 string optionName = "NtstatusXml";
108 string s = ConfigurationSettings.AppSettings[optionName];
109 VerifyRequiredOption(optionName,
110 s);
111 return s;
112 }
113 }
114
115 private static string WinerrorXml
116 {
117 get
118 {
119 string optionName = "WinerrorXml";
120 string s = ConfigurationSettings.AppSettings[optionName];
121 VerifyRequiredOption(optionName,
122 s);
123 return s;
124 }
125 }
126
127 private static string HresultXml
128 {
129 get
130 {
131 string optionName = "HresultXml";
132 string s = ConfigurationSettings.AppSettings[optionName];
133 VerifyRequiredOption(optionName,
134 s);
135 return s;
136 }
137 }
138
139 private static string WmXml
140 {
141 get
142 {
143 string optionName = "WmXml";
144 string s = ConfigurationSettings.AppSettings[optionName];
145 VerifyRequiredOption(optionName,
146 s);
147 return s;
148 }
149 }
150
151 private static string SvnCommand
152 {
153 get
154 {
155 string optionName = "SvnCommand";
156 string s = ConfigurationSettings.AppSettings[optionName];
157 VerifyRequiredOption(optionName,
158 s);
159 return s;
160 }
161 }
162
163 private static string BugUrl
164 {
165 get
166 {
167 string optionName = "BugUrl";
168 string s = ConfigurationSettings.AppSettings[optionName];
169 VerifyRequiredOption(optionName,
170 s);
171 return s;
172 }
173 }
174
175 private static string WineBugUrl
176 {
177 get
178 {
179 string optionName = "WineBugUrl";
180 string s = ConfigurationSettings.AppSettings[optionName];
181 VerifyRequiredOption(optionName,
182 s);
183 return s;
184 }
185 }
186
187
188 private static string SambaBugUrl
189 {
190 get
191 {
192 string optionName = "SambaBugUrl";
193 string s = ConfigurationSettings.AppSettings[optionName];
194 VerifyRequiredOption(optionName,
195 s);
196 return s;
197 }
198 }
199
200
201 //private static void RunIrcService()
202 //{
203 // IrcTechBotService ircService = new IrcTechBotService(IRCServerHostName,
204 // IRCServerHostPort,
205 // IRCChannelNames,
206 // IRCBotName,
207 // IRCBotPassword,
208 // ChmPath,
209 // MainChm);
210 // ircService.Run();
211 //}
212
213 public static void Main(string[] args)
214 {
215 TechBotService m_TechBot = null;
216
217 if (args.Length > 0 && args[0].ToLower().Equals("irc"))
218 {
219 m_TechBot = new IrcTechBotService(IRCServerHostName,
220 IRCServerHostPort,
221 IRCChannelNames,
222 IRCBotName,
223 IRCBotPassword,
224 ChmPath,
225 MainChm);
226 }
227 else
228 {
229 System.Console.WriteLine("TechBot running console service...");
230 m_TechBot = new ConsoleTechBotService(
231 ChmPath,
232 MainChm);
233
234
235 }
236
237 m_TechBot.Run();
238 }
239 }
240 }