private MirandaBootConfiguration() { IniStructure = IniStructure.ReadIni(MirandaEnvironment.MirandaBootIniPath); if (IniStructure == null) return; string[] keyNames = IniStructure.GetKeys(RoamieCategory); foreach (string keyName in keyNames) { int intValue; switch (keyName) { case StartupOptionKey: StartupOption = (StartupOption) Enum.Parse(typeof (StartupOption), IniStructure.GetValue(RoamieCategory, StartupOptionKey)); break; case ProfileKey: Profile = RoamiePlugin.Singleton.RoamingContext.Configuration.ProfileManager.Profiles.Find( IniStructure.GetValue(RoamieCategory, ProfileKey)); break; case PublicPcKey: if (Int32.TryParse(IniStructure.GetValue(RoamieCategory, PublicPcKey), out intValue)) PublicPc = Convert.ToBoolean(intValue); break; case SandboxModeKey: if (Int32.TryParse(IniStructure.GetValue(RoamieCategory, SandboxModeKey), out intValue)) SandboxMode = Convert.ToBoolean(intValue); break; } } }
private static string CreateData(IniStructure IniData, string comment) { //Iterates through all categories and keys and appends all data to Data int CategoryCount = IniData.GetCategories().Length; int[] KeyCountPerCategory = new int[CategoryCount]; string Data = comment; string[] temp = new string[2]; // will contain key-value pair for (int i = 0; i < CategoryCount; i++) // Gets keycount per category { string CategoryName = IniData.GetCategories()[i]; KeyCountPerCategory[i] = IniData.GetKeys(CategoryName).Length; } for (int catcounter = 0; catcounter < CategoryCount; catcounter++) { Data += "\r\n[" + IniData.GetCategoryName(catcounter) + "]\r\n"; // writes [Category] to Data for (int keycounter = 0; keycounter < KeyCountPerCategory[catcounter]; keycounter++) { temp[0] = IniData.GetKeyName(catcounter, keycounter); temp[1] = IniData.GetValue(catcounter, keycounter); Data += temp[0] + "=" + temp[1] + "\r\n"; // writes the key-value pair to Data } } return Data; }