00001 using System; 00002 using System.Collections.Generic; 00003 using System.Linq; 00004 using System.Text; 00005 using System.IO; 00006 00007 namespace system_controller { 00008 class InitializationParameters { 00009 00010 public delegate void updateErrorEventHandler(Exception error); 00011 public static event updateErrorEventHandler updateErrorEvent; 00012 00013 static Dictionary<string, string> _iniFileParameters; 00014 public static Dictionary<string, string> IniFileParameters { 00015 get { return InitializationParameters._iniFileParameters; } 00016 } 00017 00018 private static string _status = "ok"; 00019 public static string Status { 00020 get { return InitializationParameters._status; } 00021 } 00022 00023 static InitializationParameters() { 00024 } 00025 00026 public static void readIniParameters() { 00027 try { 00028 StreamReader sr = new StreamReader(".\\system_controller.ini"); 00029 string s = sr.ReadToEnd(); 00030 _iniFileParameters = new Dictionary<string, string>(); 00031 while (s.Contains("=")) { 00032 while (s.IndexOf("\r\n") < s.IndexOf("=")) 00033 s = s.Remove(0, s.IndexOf("\r\n") + 2); 00034 _iniFileParameters.Add((s.Substring(0, s.IndexOf("=")).Trim()) 00035 , (s.Substring(s.IndexOf("=") + 1, s.IndexOf("\r\n") 00036 - (s.IndexOf("=") + 1))).Trim()); 00037 s = s.Remove(0, s.IndexOf("\r\n") + 2); 00038 } 00039 } catch (Exception e) { 00040 if (updateErrorEvent != null) 00041 updateErrorEvent.Invoke(e); 00042 _status = e.Message; 00043 } 00044 } 00045 } 00046 }