public void SaveAfterTextWriter() { string filePath = "Test.ini"; StreamWriter writer = new StreamWriter(filePath); writer.WriteLine("[new section]"); writer.WriteLine(" dog = Rover"); writer.Close(); IniConfigSource source = new IniConfigSource(filePath); Assert.AreEqual(filePath, source.SavePath); StringWriter textWriter = new StringWriter(); source.Save(textWriter); Assert.IsNull(source.SavePath); File.Delete(filePath); }
private bool InsertUpdateUser(string userFile) { bool result; var userConfig = new IniConfigSource(userFile); userConfig.Configs["users"].Set(_UserName, _Password); try { userConfig.Save(); result = true; } catch (Exception) { result = false; } return(result); }
/// <summary> /// Updates the repository realm. /// </summary> /// <returns></returns> public bool UpdateRealm() { bool retval = true; var iniDoc = new IniDocument(_fullPathToConfFile, IniFileType.SambaStyle); var source = new IniConfigSource(iniDoc); source.Configs["general"].Set("realm", _repositoryRealm); try { source.Save(_fullPathToConfFile); } catch { retval = false; } return(retval); }
/// <summary> /// Applies any Delete modifications /// </summary> /// <param name="mod">The mod.</param> private void Delete(IniDelete mod) { try { IConfigSource target = new IniConfigSource(targetFile); if (config.BreakOnNoMatch && !target.Configs[mod.section].Contains(mod.key)) { throw new Exception("Could not match section"); } target.Configs[mod.section].Remove(mod.key); target.Save(); LogCount(log); } catch (Exception inner) { throw new Exception("Failed to process Delete modification to Section/Key = " + mod.section + "/" + mod.key, inner); } }
public static void Load() { Ini = new IniConfigSource("Settings.ini"); Core = Ini.Configs["Core"]; Network = Ini.Configs["Network"]; Users = Ini.Configs["Users"]; // Cleanup Log.Debug("Settings", "Cleaning up expired entries"); foreach (var key in Users.GetKeys()) { if (IsUserExpired(key)) { Users.Remove(key); } } Ini.Save(); Log.Debug("Settings", "Saved cleaned up settings"); }
private bool DeleteUser(string userFile) { var userConfig = new IniConfigSource(userFile); userConfig.Configs["users"].Remove(_UserName); bool result; try { userConfig.Save(); result = true; } catch (Exception) { result = false; } return(result); }
private void btn_OK_Click(object sender, EventArgs e) { try { IConfigSource source = new IniConfigSource(fc.INIPath); source.Configs[fc.DBINFOConfig].Set("IP", edLocalDBIP.Text); source.Configs[fc.DBINFOConfig].Set("DB", edLocalDBName.Text); source.Configs[fc.DBINFOConfig].Set("ID", edLocalDBid.Text); source.Configs[fc.DBINFOConfig].Set("PW", fc.FDes.EncryptString(edLocalDBpass.Text, fc.FDes.GenerateKey())); source.Save(); fc.FDBInfo.SetDBInfo(edLocalDBIP.Text, edLocalDBName.Text, edLocalDBid.Text, edLocalDBpass.Text); this.Close(); } catch (System.Exception ex) { MessageBox.Show(ex.Message.ToString()); fc.ErrorLog(ex.Message); return; } }
public static void UpdateIniFile(string fileName, string handler, string[] names, string[] values, MigratorAction[] actions) { if (File.Exists(fileName + ".example"))//Update the .example files too if people haven't UpdateIniFile(fileName + ".example", handler, names, values, actions); if (File.Exists(fileName)) { IniConfigSource doc = new IniConfigSource(fileName, IniFileType.AuroraStyle); IConfig section = doc.Configs[handler]; for (int i = 0; i < names.Length; i++) { string name = names[i]; string value = values[i]; MigratorAction action = actions[i]; if (action == MigratorAction.Add) section.Set(name, value); else section.Remove(name); } doc.Save(); } }
private void new_settings() { config.Set("config.ini", "MyNewSavedFile.log"); IConfigSource source = new IniConfigSource("config.ini"); int newwidth = System.Convert.ToInt32(this.textBox1.Text); int newheight = System.Convert.ToInt32(this.textBox2.Text); int newscrollspeed = System.Convert.ToInt32(this.textBox3.Text); int newtoolbarspeed = System.Convert.ToInt32(this.textBox4.Text); int newshowminmap = System.Convert.ToInt32(this.textBox5.Text); int newarrowInverted = System.Convert.ToInt32(this.textBox6.Text); config.Set(defaultwidth, newwidth); config.Set(defaultheight, newheight); config.Set(scrollspeed, newscrollspeed); config.Set(toolbarspeed, newtoolbarspeed); config.Set(showminmap, newshowminmap); config.Set(arrowInverted, newarrowInverted); source.Save(); }
public void Save(string name) { string fileName = name + ".cset"; var configSource = new IniConfigSource(fileName); var conf = configSource.AddConfig("Mobs"); for (int i = 0; i < MobIds.Length; i++) { int mId = MobIds[i]; conf.Set("Mob" + i, mId); } conf = configSource.AddConfig("Place"); conf.Set("CoordX", StartCoords.GameX); conf.Set("CoordY", StartCoords.GameX); conf.Set("CoordZ", StartCoords.GameX); configSource.Save(); }
private bool DeleteAdminUser() { bool result; string userFile = Common.GetCorrectedPath(_RepositoryPath, true) + "administrators.txt"; var userConfig = new IniConfigSource(userFile); userConfig.Configs["users"].Remove(_UserName); try { userConfig.Save(); result = true; } catch (Exception) { result = false; } return(result); }
public void Start(int posX, int posY) { IConfigSource playerIni = new IniConfigSource(Options.GetClientPath() + "\\player.ini"); if (playerIni.Configs["run"] == null) { playerIni.AddConfig("run"); } playerIni.Configs["run"].Set("fast", "true"); playerIni.Save(); m_clientLoadInfo = new ProcessStartInfo(Options.GetClientPath() + "\\player.exe"); if (m_clientLoadInfo != null) { m_clientLoadInfo.UseShellExecute = true; m_clientLoadInfo.WorkingDirectory = Options.GetClientPath(); m_clientLoadInfo.ErrorDialog = true; try { if (m_clientProcess == null || m_clientProcess.HasExited) { m_clientProcess = Process.Start(m_clientLoadInfo); m_clientProcess.EnableRaisingEvents = true; RemoveCloseButton(GetClientWindowHandle()); MoveClientWindow(posX, posY); } else { MessageBox.Show(" лиент уже загружен.\nƒл¤ загрузки нового закройте старый", "ќшибка загрузки", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Win32Exception w) { MessageBox.Show(" лиент не может быть загружен.\n" + w.Message, "ќшибка загрузки", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
/// <summary> /// Updates the sasl data. /// </summary> /// <returns></returns> public bool UpdateSaslData() { bool retval = true; var iniDoc = new IniDocument(_fullPathToConfFile, IniFileType.SambaStyle); var source = new IniConfigSource(iniDoc); source.Configs["sasl"].Set("use-sasl", _isSaslAvailable); source.Configs["sasl"].Set("min-encryption", _minSaslEncryption); source.Configs["sasl"].Set("max-encryption", _maxSaslEncryption); try { source.Save(_fullPathToConfFile); } catch { retval = false; } return(retval); }
public IniFileConfiguration(string iniFile) { if (string.IsNullOrWhiteSpace(iniFile)) { throw new ArgumentException("Имя ini файла должно быть указано.", nameof(iniFile)); } this.IniFile = iniFile; if (File.Exists(iniFile)) { configSource = new IniConfigSource(iniFile); configSource.Reload(); } else { logger.Warn("Конфигурационный фаил {0} не найден. Создан новый.", iniFile); configSource = new IniConfigSource(); configSource.Save(iniFile); } configSource.AutoSave = true; }
/// <summary> /// Updates the repository authorization settings in the svnserve.conf file. /// </summary> /// <returns></returns> public bool UpdateAuthorization() { bool retval = true; string anon = _AnonymousAccess.ToString().ToLower(); string auth = _AuthorizedAccess.ToString().ToLower(); var iniDoc = new IniDocument(_fullPathToConfFile, IniFileType.SambaStyle); var source = new IniConfigSource(iniDoc); source.Configs["general"].Set("anon-access", anon); source.Configs["general"].Set("auth-access", auth); try { source.Save(_fullPathToConfFile); } catch { retval = false; } return(retval); }
// We call this from our plugin module to get our configuration public IConfig GetConfig() { IConfig config = null; config = ServerUtils.GetConfig(ConfigFile, ConfigName); // Our file is not here? We can get one to bootstrap our plugin module if (config == null) { IConfigSource remotesource = GetConfigSource(); if (remotesource != null) { IniConfigSource initialconfig = new IniConfigSource(); initialconfig.Merge(remotesource); initialconfig.Save(ConfigFile); } config = remotesource.Configs[ConfigName]; } return(config); }
static PromOptions() { if (!File.Exists(SettingsFilename)) { //Set default values for system options RegistryKey rk; rk = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Microsoft Games\\Halo", false); string PcInstallPath = (String)rk.GetValue("EXE Path"); rk.Close(); HaloPC_BitmapsPath = PcInstallPath + @"\maps\bitmaps.map"; HaloPC_SoundsPath = PcInstallPath + @"\maps\sounds.map"; rk = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Microsoft Games\\Halo CE", false); string CeInstallPath = (String)rk.GetValue("EXE Path"); rk.Close(); HaloCE_BitmapsPath = CeInstallPath + @"\maps\bitmaps.map"; HaloCE_SoundsPath = CeInstallPath + @"\maps\sounds.map"; //Create the default ini file IniConfigSource source = new IniConfigSource(); IConfig config = source.AddConfig("Decompiler"); config.Set("HaloPC_BitmapsPath", HaloPC_BitmapsPath); config.Set("HaloPC_SoundsPath", HaloPC_SoundsPath); config.Set("HaloCE_BitmapsPath", HaloCE_BitmapsPath); config.Set("HaloCE_SoundsPath", HaloCE_SoundsPath); config.Set("XHalo1_UiPath", ""); config.Set("XHalo2_SharedPath", ""); config.Set("XHalo2_SinglePlayerSharedPath", ""); config.Set("XHalo2_MainMenuPath", ""); //config = source.AddConfig ("Logging"); //config.Set ("FilePath", "C:\\temp\\MyApp.log"); source.Save(SettingsFilename); } }
public void SetAndSave() { string filePath = "Test.ini"; StreamWriter writer = new StreamWriter(filePath); writer.WriteLine("; some comment"); writer.WriteLine("[new section]"); writer.WriteLine(" dog = Rover"); writer.WriteLine(""); // empty line writer.WriteLine("; a comment"); writer.WriteLine(" cat = Muffy"); writer.Close(); IniConfigSource source = new IniConfigSource(filePath); IConfig config = source.Configs["new section"]; Assert.AreEqual("Rover", config.Get("dog")); Assert.AreEqual("Muffy", config.Get("cat")); config.Set("dog", "Spots"); config.Set("cat", "Misha"); config.Set("DoesNotExist", "SomeValue"); Assert.AreEqual("Spots", config.Get("dog")); Assert.AreEqual("Misha", config.Get("cat")); Assert.AreEqual("SomeValue", config.Get("DoesNotExist")); source.Save(); source = new IniConfigSource(filePath); config = source.Configs["new section"]; Assert.AreEqual("Spots", config.Get("dog")); Assert.AreEqual("Misha", config.Get("cat")); Assert.AreEqual("SomeValue", config.Get("DoesNotExist")); File.Delete(filePath); }
public void SaveRegionToFile(string description, string filename) { if (filename.ToLower().EndsWith(".ini")) { IniConfigSource source = new IniConfigSource(); try { source = new IniConfigSource(filename); // Load if it exists } catch (Exception) { } WriteNiniConfig(source); source.Save(filename); return; } configMember = new ConfigurationMember(filename, description, loadConfigurationOptionsFromMe, ignoreIncomingConfiguration, false); configMember.performConfigurationRetrieve(); RegionFile = filename; }
public void SaveRegionToFile(string description, string filename) { if (filename.ToLower().EndsWith(".ini")) { IniConfigSource source = new IniConfigSource(); try { source = new IniConfigSource(filename); // Load if it exists } catch (Exception) { } WriteNiniConfig(source); source.Save(filename); return; } else { throw new Exception("Invalid file type for region persistence."); } }
public static void Configure(bool requested) { string WhiteCore_ConfigDir = Constants.DEFAULT_CONFIG_DIR; bool isWhiteCoreExe = AppDomain.CurrentDomain.FriendlyName == "WhiteCore.exe" || AppDomain.CurrentDomain.FriendlyName == "WhiteCore.vshost.exe"; bool existingConfig = ( File.Exists(Path.Combine(WhiteCore_ConfigDir, "MyWorld.ini")) || File.Exists(Path.Combine(WhiteCore_ConfigDir, "MyGrid.ini")) || File.Exists(Path.Combine(WhiteCore_ConfigDir, "WhiteCore.ini")) || File.Exists(Path.Combine(WhiteCore_ConfigDir, "WhiteCore.Server.ini")) ); if (requested || !existingConfig) { string resp = "no"; if (!requested) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\n\n************* WhiteCore-Sim initial run. *************"); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine( "\n\n This appears to be your first time running WhiteCore-Sim.\n" + "If you have already configured your *.ini files, please ignore this warning and press enter;\n" + "Otherwise type 'yes' and WhiteCore-Sim will guide you through the configuration process.\n\n" + "Remember, these file names are Case Sensitive in Linux and Proper Cased.\n" + "1. " + WhiteCore_ConfigDir + "/WhiteCore.ini\nand\n" + "2. " + WhiteCore_ConfigDir + "/Sim/Standalone/StandaloneCommon.ini \nor\n" + "3. " + WhiteCore_ConfigDir + "/Grid/GridCommon.ini\n" + "\nAlso, you will want to examine these files in great detail because only the basic system will " + "load by default. WhiteCore-Sim can do a LOT more if you spend a little time going through these files.\n\n"); } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\n\n************* WhiteCore-Sim Configuration *************"); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine( "\n WhiteCore interactive configuration.\n" + "Enter 'yes' and WhiteCore-Sim will guide you through the configuration process."); } // Make sure... Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(""); Console.WriteLine(" ## WARNING - WARNING - WARNING - WARNING - WARNING ##\n"); Console.WriteLine("This will overwrite any existing configuration files!"); Console.WriteLine("It is strongly recommended that you save a backup copy"); Console.WriteLine("of your configuration files before proceeding!"); Console.ResetColor(); Console.WriteLine(""); resp = ReadLine("Do you want to configure WhiteCore-Sim now? (yes/no)", resp); if (resp == "yes") { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("\n Just a moment... getting some details...\n"); string cfgFolder = WhiteCore_ConfigDir + "/"; // Main Config folder >> "../Config" (default) string dbSource = "localhost"; string dbPasswd = "whitecore"; string dbSchema = "whitecore"; string dbUser = "******"; string dbPort = "3306"; string gridIPAddress = Utilities.GetExternalIp(); string regionIPAddress = gridIPAddress; bool isStandalone = true; string dbType = "1"; string assetType = "1"; string gridName = "WhiteCore-Sim"; string welcomeMessage = ""; string allowAnonLogin = "******"; uint port = 9000; uint gridPort = 8002; Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("===================================================================="); Console.WriteLine("======================= WhiteCore-Sim Configurator ================="); Console.WriteLine("===================================================================="); Console.ResetColor(); if (isWhiteCoreExe) { Console.WriteLine("This installation is going to run in"); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("[1] Standalone Mode \n[2] Grid Mode"); Console.ResetColor(); isStandalone = ReadLine("Choose 1 or 2", "1") == "1"; Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("The domain name or IP address of this region server\nThe default is your external IP address"); Console.ResetColor(); regionIPAddress = ReadLine("Region server address: ", regionIPAddress); Console.WriteLine("\nHttp Port for the region server"); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("Default is 9000"); Console.ResetColor(); port = uint.Parse(ReadLine("Choose the port", "9000")); } if (isStandalone) { Console.WriteLine("Which database do you want to use?"); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("[1] SQLite \n[2] MySQL"); Console.ResetColor(); dbType = ReadLine("Choose 1 or 2", dbType); if (dbType == "2") { Console.ForegroundColor = ConsoleColor.White; Console.WriteLine( "\nNote: this setup does not automatically create a MySQL installation for you.\n" + " This will configure the WhiteCore setting but you must install MySQL as well"); Console.ResetColor(); dbSource = ReadLine("MySQL database IP", dbSource); dbPort = ReadLine("MySQL database port (if not default)", dbPort); dbSchema = ReadLine("MySQL database name for your region", dbSchema); dbUser = ReadLine("MySQL database user account", dbUser); Console.Write("MySQL database password for that account"); dbPasswd = Console.ReadLine(); Console.WriteLine(""); } } if (isStandalone) { gridName = ReadLine("Name of your WhiteCore-Sim server", gridName); welcomeMessage = "Welcome to " + gridName + ", <USERNAME>!"; Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("\nEnter your 'Welcome Message' that each user will see during login\n" + " (putting <USERNAME> into the welcome message will insert the user's name)"); Console.ResetColor(); welcomeMessage = ReadLine("Welcome Message", welcomeMessage); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("\nAccounts can be created automatically when users log in for the first time.\n" + " (This means you don't have to create all accounts manually using the console or web interface)"); Console.ResetColor(); allowAnonLogin = ReadLine("Create accounts automatically?", allowAnonLogin); } if (!isStandalone) { gridIPAddress = ReadLine("The domain name or IP address of the grid server you wish to connect to", gridIPAddress); } //Data.ini setup if (isStandalone) { string cfgDataFolder = isWhiteCoreExe ? "Sim/" : "Grid/ServerConfiguration/"; MakeSureExists(cfgFolder + cfgDataFolder + "Data/Data.ini"); var data_ini = new IniConfigSource( cfgFolder + cfgDataFolder + "Data/Data.ini", Nini.Ini.IniFileType.AuroraStyle); IConfig conf = data_ini.AddConfig("DataFile"); // DB include if (dbType == "1") { conf.Set("Include-SQLite", cfgDataFolder + "Data/SQLite.ini"); } else { conf.Set("Include-MySQL", cfgDataFolder + "Data/MySQL.ini"); } if (isWhiteCoreExe) { conf.Set("Include-FileBased", "Sim/Data/FileBased.ini"); } // Asset services conf = data_ini.AddConfig("Handlers"); Console.WriteLine("Which asset service do you want to use?"); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("[1] File based\n[2] SQL"); Console.ResetColor(); assetType = ReadLine("Choose 1 or 2", assetType); if (assetType == "2") { conf.Set("AssetHandler", "AssetService"); } else { conf.Set("AssetHandler", "FileBasedAssetService"); } conf.Set("AssetHandlerUseCache", false); conf = data_ini.AddConfig("WhiteCoreConnectors"); conf.Set("ValidateTables", true); data_ini.Save(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Your Data.ini has been successfully configured"); Console.ResetColor(); // MySql setup if (dbType == "2") { MakeSureExists(cfgFolder + cfgDataFolder + "Data/MySQL.ini"); var mysql_ini = new IniConfigSource( cfgFolder + cfgDataFolder + "Data/MySQL.ini", Nini.Ini.IniFileType.AuroraStyle); var mysql_ini_example = new IniConfigSource( cfgFolder + cfgDataFolder + "Data/MySQL.ini.example", Nini.Ini.IniFileType.AuroraStyle); foreach (IConfig config in mysql_ini_example.Configs) { IConfig newConfig = mysql_ini.AddConfig(config.Name); foreach (string key in config.GetKeys()) { if (key == "ConnectionString") { newConfig.Set(key, string.Format( "\"Data Source={0};Port={1};Database={2};User ID={3};Password={4};Charset=utf8;\"", dbSource, dbPort, dbSchema, dbUser, dbPasswd)); } else { newConfig.Set(key, config.Get(key)); } } } mysql_ini.Save(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Your MySQL.ini has been successfully configured"); Console.ResetColor(); } } // Region server if (isWhiteCoreExe) { MakeSureExists(cfgFolder + "WhiteCore.ini"); var whitecore_ini = new IniConfigSource( cfgFolder + "WhiteCore.ini", Nini.Ini.IniFileType.AuroraStyle); var whitecore_ini_example = new IniConfigSource( cfgFolder + "WhiteCore.ini.example", Nini.Ini.IniFileType.AuroraStyle); bool setIp = false; foreach (IConfig config in whitecore_ini_example.Configs) { IConfig newConfig = whitecore_ini.AddConfig(config.Name); foreach (string key in config.GetKeys()) { if (key == "http_listener_port") { newConfig.Set(key, port); } else if (key == "HostName") { setIp = true; newConfig.Set(key, regionIPAddress); } else { newConfig.Set(key, config.Get(key)); } } if ((config.Name == "Network") & !setIp) { setIp = true; newConfig.Set("HostName", regionIPAddress); } } whitecore_ini.Save(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Your WhiteCore.ini has been successfully configured"); Console.ResetColor(); MakeSureExists(cfgFolder + "Sim/Main.ini"); var main_ini = new IniConfigSource( cfgFolder + "Sim/Main.ini", Nini.Ini.IniFileType.AuroraStyle); IConfig conf = main_ini.AddConfig("Architecture"); if (isStandalone) { conf.Set("Include-Standalone", "Sim/Standalone/StandaloneCommon.ini"); } else { conf.Set("Include-Grid", "Sim/Grid/GridCommon.ini"); } conf.Set("Include-Includes", "Sim/Includes.ini"); main_ini.Save(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Your Main.ini has been successfully configured"); Console.ResetColor(); if (isStandalone) { MakeSureExists(cfgFolder + "Sim/Standalone/StandaloneCommon.ini"); var standalone_ini = new IniConfigSource( cfgFolder + "Sim/Standalone/StandaloneCommon.ini", Nini.Ini.IniFileType.AuroraStyle); var standalone_ini_example = new IniConfigSource( cfgFolder + "Sim/Standalone/StandaloneCommon.ini.example", Nini.Ini.IniFileType.AuroraStyle); foreach (IConfig config in standalone_ini_example.Configs) { IConfig newConfig = standalone_ini.AddConfig(config.Name); if (newConfig.Name == "GridInfoService") { newConfig.Set("GridInfoInHandlerPort", 0); newConfig.Set("login", "http://" + gridIPAddress + ":" + port + "/"); newConfig.Set("gridname", gridName); newConfig.Set("gridnick", gridName); } else { foreach (string key in config.GetKeys()) { if (key == "WelcomeMessage") { newConfig.Set(key, welcomeMessage); } else if (key == "AllowAnonymousLogin") { newConfig.Set(key, allowAnonLogin); } else { newConfig.Set(key, config.Get(key)); } } } } standalone_ini.Save(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Your StandaloneCommon.ini has been successfully configured"); Console.ResetColor(); } else { MakeSureExists(cfgFolder + "Sim/Grid/GridCommon.ini"); var grid_ini = new IniConfigSource( cfgFolder + "Sim/Grid/GridCommon.ini", Nini.Ini.IniFileType.AuroraStyle); conf = grid_ini.AddConfig("Includes"); conf.Set("Include-Grid", "Sim/Grid/Grid.ini"); conf = grid_ini.AddConfig("Configuration"); conf.Set("GridServerURI", "http://" + gridIPAddress + ":8012/grid/"); //Lets tell the Configurator to create the missing .ini entrys from the .example file conf.Set("SendGridInfoToViewerOnLogin", "true"); conf.Set("CurrencySymbol", "\"WC$\""); conf.Set(";;DISABLED BY DEFAULT GENERATED BY CONFIGURATOR", ""); conf.Set(";;welcome", "http://" + gridIPAddress + "/welcome"); conf.Set(";;economy", "http://" + gridIPAddress + ":8009/"); conf.Set(";;about", "http://" + gridIPAddress + "/about"); conf.Set(";;register", "http://" + gridIPAddress + "/register"); conf.Set(";;help", "http://" + gridIPAddress + "/help"); conf.Set(";;forgottenpassword", "http://" + gridIPAddress + "/password"); conf.Set(";;map", ""); conf.Set(";;webprofile", ""); conf.Set(";;search", ""); conf.Set(";;destination", ""); conf.Set(";;marketplace", ""); conf.Set(";;tutorial", ""); conf.Set(";;message", "\"this is a test message\""); conf.Set(";;snapshotconfig", ""); conf.Set(";;RealCurrencySymbol", "\"$\""); conf.Set(";;MaxGroups", "50"); grid_ini.Save(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Your Grid.ini has been successfully configured"); Console.ResetColor(); Console.WriteLine(""); } } // Grid server if (!isWhiteCoreExe) { MakeSureExists(cfgFolder + "WhiteCore.Server.ini"); var whitecore_ini = new IniConfigSource( cfgFolder + "WhiteCore.Server.ini", Nini.Ini.IniFileType.AuroraStyle); var whitecore_ini_example = new IniConfigSource( cfgFolder + "WhiteCore.Server.ini.example", Nini.Ini.IniFileType.AuroraStyle); gridIPAddress = ReadLine("\nThe domain name or IP address of the grid server", gridIPAddress); bool ipSet = false; foreach (IConfig config in whitecore_ini_example.Configs) { IConfig newConfig = whitecore_ini.AddConfig(config.Name); foreach (string key in config.GetKeys()) { if (key == "HostName") { ipSet = true; newConfig.Set(key, gridIPAddress); } else { newConfig.Set(key, config.Get(key)); } } if ((config.Name == "Network") & !ipSet) { ipSet = true; newConfig.Set("HostName", gridIPAddress); } } whitecore_ini.Save(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Your WhiteCore.Server.ini has been successfully configured"); Console.ResetColor(); MakeSureExists(cfgFolder + "Grid/ServerConfiguration/Login.ini"); var login_ini = new IniConfigSource( cfgFolder + "Grid/ServerConfiguration/Login.ini", Nini.Ini.IniFileType.AuroraStyle); var login_ini_example = new IniConfigSource( cfgFolder + "Grid/ServerConfiguration/Login.ini.example", Nini.Ini.IniFileType.AuroraStyle); Console.WriteLine("\nHttp Port for the grid server"); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("Default is 8002"); Console.ResetColor(); gridPort = uint.Parse(ReadLine("Choose the port", "8002")); foreach (IConfig config in login_ini_example.Configs) { IConfig newConfig = login_ini.AddConfig(config.Name); foreach (string key in config.GetKeys()) { if (key == "WelcomeMessage") { newConfig.Set(key, welcomeMessage); } else if (key == "AllowAnonymousLogin") { newConfig.Set(key, allowAnonLogin); } else { newConfig.Set(key, config.Get(key)); } } } login_ini.Save(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Your Login.ini has been successfully configured"); Console.ResetColor(); MakeSureExists(cfgFolder + "Grid/ServerConfiguration/GridInfoService.ini"); var grid_info_ini = new IniConfigSource( cfgFolder + "Grid/ServerConfiguration/GridInfoService.ini", Nini.Ini.IniFileType.AuroraStyle); IConfig conf = grid_info_ini.AddConfig("GridInfoService"); conf.Set("GridInfoInHandlerPort", gridPort); conf.Set("login", "http://" + gridIPAddress + ":" + gridPort + "/"); conf.Set("gridname", gridName); conf.Set("gridnick", gridName); grid_info_ini.Save(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Your GridInfoService.ini has been successfully configured"); Console.ResetColor(); Console.WriteLine(""); } Console.WriteLine("\n====================================================================\n"); Console.ResetColor(); Console.WriteLine("Your grid name is "); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine(gridName); Console.ResetColor(); if (isStandalone) { Console.WriteLine("\nYour loginuri is "); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("http://" + (isWhiteCoreExe ? regionIPAddress : gridIPAddress) + ":" + (isWhiteCoreExe ? port : gridPort) + "/"); Console.ResetColor(); } else { Console.WriteLine("\nConnected Grid URL: "); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("http://" + gridIPAddress + ":" + gridPort + "/"); Console.ResetColor(); } Console.WriteLine("\n====================================================================\n"); Console.WriteLine( "To re-run this configurator, enter \"run configurator\" into the console."); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(" >> Please restart WhiteCore-Sim to use your new configuration. <<"); Console.ResetColor(); Console.WriteLine(""); } } }
/// <summary> /// Change and load configuration file data. /// </summary> /// <param name="module"></param> /// <param name="cmd"></param> private void HandleConfig(string module, string[] cmd) { List <string> args = new List <string>(cmd); args.RemoveAt(0); string[] cmdparams = args.ToArray(); if (cmdparams.Length > 0) { string firstParam = cmdparams[0].ToLower(); switch (firstParam) { case "set": if (cmdparams.Length < 4) { Notice("Syntax: config set <section> <key> <value>"); Notice("Example: config set ScriptEngine.DotNetEngine NumberOfScriptThreads 5"); } else { IConfig c; IConfigSource source = new IniConfigSource(); c = source.AddConfig(cmdparams[1]); if (c != null) { string _value = String.Join(" ", cmdparams, 3, cmdparams.Length - 3); c.Set(cmdparams[2], _value); Config.Merge(source); Notice("In section [{0}], set {1} = {2}", c.Name, cmdparams[2], _value); } } break; case "get": case "show": if (cmdparams.Length == 1) { foreach (IConfig config in Config.Configs) { Notice("[{0}]", config.Name); string[] keys = config.GetKeys(); foreach (string key in keys) { Notice(" {0} = {1}", key, config.GetString(key)); } } } else if (cmdparams.Length == 2 || cmdparams.Length == 3) { IConfig config = Config.Configs[cmdparams[1]]; if (config == null) { Notice("Section \"{0}\" does not exist.", cmdparams[1]); break; } else { if (cmdparams.Length == 2) { Notice("[{0}]", config.Name); foreach (string key in config.GetKeys()) { Notice(" {0} = {1}", key, config.GetString(key)); } } else { Notice( "config get {0} {1} : {2}", cmdparams[1], cmdparams[2], config.GetString(cmdparams[2])); } } } else { Notice("Syntax: config {0} [<section>] [<key>]", firstParam); Notice("Example: config {0} ScriptEngine.DotNetEngine NumberOfScriptThreads", firstParam); } break; case "save": if (cmdparams.Length < 2) { Notice("Syntax: config save <path>"); return; } string path = cmdparams[1]; Notice("Saving configuration file: {0}", path); if (Config is IniConfigSource) { IniConfigSource iniCon = (IniConfigSource)Config; iniCon.Save(path); } else if (Config is XmlConfigSource) { XmlConfigSource xmlCon = (XmlConfigSource)Config; xmlCon.Save(path); } break; } } }
internal void Save() { _source.Save(); }
internal static void Save() { Source.Save(); }
public static void SaveConfigFile() { ConfigSource.Save(FullConfigPath); }
public static void Configure(bool requested) { string Aurora_ConfigDir = Constants.DEFAULT_CONFIG_DIR; bool isAuroraExe = AppDomain.CurrentDomain.FriendlyName == "Aurora.exe" || AppDomain.CurrentDomain.FriendlyName == "Aurora.vshost.exe"; bool existingConfig = ( File.Exists(Path.Combine(Aurora_ConfigDir, "MyWorld.ini")) || File.Exists(Path.Combine(Aurora_ConfigDir, "Aurora.ini")) || File.Exists(Path.Combine(Aurora_ConfigDir, "Aurora.Server.ini")) ); if (requested || !existingConfig) { string resp = "no"; if (!requested) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\n\n************* Aurora Initial Run. *************"); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine( "\n\n This appears to be your first time running Aurora.\n" + "If you have already configured your *.ini files, please ignore this warning and press enter;\n" + "Otherwise type 'yes' and Aurora will guide you through the configuration process.\n\n" + "Remember, these file names are Case Sensitive in Linux and Proper Cased.\n" + "1. " + Aurora_ConfigDir + "/Aurora.ini\nand\n" + "2. " + Aurora_ConfigDir + "/Sim/Standalone/StandaloneCommon.ini \nor\n" + "3. " + Aurora_ConfigDir + "/Grid/GridCommon.ini\n" + "\nAlso, you will want to examine these files in great detail because only the basic system will " + "load by default. Aurora can do a LOT more if you spend a little time going through these files.\n\n"); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("This will overwrite any existing configuration files for your sim"); Console.ResetColor(); resp = ReadLine("Do you want to configure Aurora now", resp); } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("This will overwrite any existing configuration files for your sim"); Console.ResetColor(); resp = ReadLine("Do you want to configure Aurora now", resp); } if (resp == "yes") { string dbSource = "localhost"; string dbPasswd = "Aurora"; string dbSchema = "Aurora"; string dbUser = "******"; string dbPort = "3306"; string gridIPAddress = Utilities.GetExternalIp(); bool isStandalone = true; string dbType = "1"; string gridName = "Aurora Grid"; string welcomeMessage = ""; string allowAnonLogin = "******"; uint port = 9000; Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("===================================================================="); Console.WriteLine("======================= Aurora CONFIGURATOR ====================="); Console.WriteLine("===================================================================="); Console.ResetColor(); if (isAuroraExe) { Console.WriteLine("This installation is going to run in"); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("[1] Standalone Mode \n[2] Grid Mode"); Console.ResetColor(); isStandalone = ReadLine("Choose 1 or 2", "1") == "1"; Console.WriteLine("Http Port for the server"); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("Default is 9000"); Console.ResetColor(); port = uint.Parse(ReadLine("Choose the port", "9000")); } if (isStandalone) { Console.WriteLine("Which database do you want to use?"); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("[1] SQLite \n[2] MySQL"); Console.ResetColor(); dbType = ReadLine("Choose 1 or 2", dbType); if (dbType == "2") { Console.WriteLine( "Note: this setup does not automatically create a MySQL installation for you.\n" + " This will configure the Aurora setting but you must install MySQL as well"); dbSource = ReadLine("MySQL database IP", dbSource); dbPort = ReadLine("MySQL database port (if not default)", dbPort); dbSchema = ReadLine("MySQL database name for your region", dbSchema); dbUser = ReadLine("MySQL database user account", dbUser); Console.Write("MySQL database password for that account: "); dbPasswd = Console.ReadLine(); } } if (isStandalone) { gridName = ReadLine("Name of your Aurora Grid", gridName); welcomeMessage = "Welcome to " + gridName + ", <USERNAME>!"; welcomeMessage = ReadLine("Welcome Message to show during login\n" + " (putting <USERNAME> into the welcome message will insert the user's name)", welcomeMessage); allowAnonLogin = ReadLine("Create accounts automatically when users log in\n" + " (This means you don't have to create all accounts manually\n" + " using the console or web interface): ", allowAnonLogin); } if (!isStandalone) { gridIPAddress = ReadLine("The external domain name or IP address of the grid server you wish to connect to", gridIPAddress); } //Data.ini setup if (isStandalone) { string folder = isAuroraExe ? Aurora_ConfigDir + "/Sim/" : Aurora_ConfigDir + "/Grid/ServerConfiguration/"; MakeSureExists(folder + "Data/Data.ini"); IniConfigSource data_ini = new IniConfigSource(folder + "Data/Data.ini", Nini.Ini.IniFileType.AuroraStyle); IConfig conf = data_ini.AddConfig("DataFile"); if (dbType == "1") { conf.Set("Include-SQLite", folder + "Data/SQLite.ini"); } else { conf.Set("Include-MySQL", folder + "Data/MySQL.ini"); } if (isAuroraExe) { conf.Set("Include-FileBased", "Sim/Data/FileBased.ini"); } conf = data_ini.AddConfig("AuroraConnectors"); conf.Set("ValidateTables", true); data_ini.Save(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Your Data.ini has been successfully configured"); Console.ResetColor(); if (dbType == "2") //MySQL setup { MakeSureExists(folder + "Data/MySQL.ini"); IniConfigSource mysql_ini = new IniConfigSource(folder + "Data/MySQL.ini", Nini.Ini.IniFileType.AuroraStyle); IniConfigSource mysql_ini_example = new IniConfigSource(folder + "Data/MySQL.ini.example", Nini.Ini.IniFileType.AuroraStyle); foreach (IConfig config in mysql_ini_example.Configs) { IConfig newConfig = mysql_ini.AddConfig(config.Name); foreach (string key in config.GetKeys()) { if (key == "ConnectionString") { newConfig.Set(key, string.Format( "\"Data Source={0};Port={1};Database={2};User ID={3};Password={4};\"", dbSource, dbPort, dbSchema, dbUser, dbPasswd)); } else { newConfig.Set(key, config.Get(key)); } } } mysql_ini.Save(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Your MySQL.ini has been successfully configured"); Console.ResetColor(); } } if (isAuroraExe) { string folder = Aurora_ConfigDir; MakeSureExists(folder + "/Aurora.ini"); IniConfigSource aurora_ini = new IniConfigSource(folder + "/Aurora.ini", Nini.Ini.IniFileType.AuroraStyle); IniConfigSource aurora_ini_example = new IniConfigSource(folder + "/Aurora.ini.example", Nini.Ini.IniFileType.AuroraStyle); foreach (IConfig config in aurora_ini_example.Configs) { IConfig newConfig = aurora_ini.AddConfig(config.Name); foreach (string key in config.GetKeys()) { if (key == "http_listener_port") { newConfig.Set(key, port); } else { newConfig.Set(key, config.Get(key)); } } } aurora_ini.Save(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Your Aurora.ini has been successfully configured"); Console.ResetColor(); MakeSureExists(folder + "/Sim/Main.ini"); IniConfigSource main_ini = new IniConfigSource(folder + "/Sim/Main.ini", Nini.Ini.IniFileType.AuroraStyle); IConfig conf = main_ini.AddConfig("Architecture"); if (isStandalone) { conf.Set("Include-Standalone", "Sim/Standalone/StandaloneCommon.ini"); } else { conf.Set("Include-Grid", "Sim/Grid/AuroraGridCommon.ini"); } conf.Set("Include-Includes", "Sim/Includes.ini"); main_ini.Save(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Your Main.ini has been successfully configured"); Console.ResetColor(); if (isStandalone) { MakeSureExists(folder + "/Sim/Standalone/StandaloneCommon.ini"); IniConfigSource standalone_ini = new IniConfigSource(folder + "/Sim/Standalone/StandaloneCommon.ini", Nini.Ini.IniFileType.AuroraStyle); IniConfigSource standalone_ini_example = new IniConfigSource(folder + "/Sim/Standalone/StandaloneCommon.ini.example", Nini.Ini.IniFileType.AuroraStyle); foreach (IConfig config in standalone_ini_example.Configs) { IConfig newConfig = standalone_ini.AddConfig(config.Name); if (newConfig.Name == "GridInfoService") { newConfig.Set("GridInfoInHandlerPort", 0); newConfig.Set("login", "http://" + gridIPAddress + ":9000/"); newConfig.Set("gridname", gridName); newConfig.Set("gridnick", gridName); } else { foreach (string key in config.GetKeys()) { if (key == "WelcomeMessage") { newConfig.Set(key, welcomeMessage); } else if (key == "AllowAnonymousLogin") { newConfig.Set(key, allowAnonLogin); } else { newConfig.Set(key, config.Get(key)); } } } } standalone_ini.Save(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Your StandaloneCommon.ini has been successfully configured"); Console.ResetColor(); } else { MakeSureExists("Sim/Grid/AuroraGridCommon.ini"); IniConfigSource grid_ini = new IniConfigSource("Sim/Grid/AuroraGridCommon.ini", Nini.Ini.IniFileType.AuroraStyle); conf = grid_ini.AddConfig("Includes"); conf.Set("Include-Grid", "Sim/Grid/Grid.ini"); conf = grid_ini.AddConfig("Configuration"); conf.Set("GridServerURI", "http://" + gridIPAddress + ":8012/grid/"); grid_ini.Save(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Your Grid.ini has been successfully configured"); Console.ResetColor(); } } if (!isAuroraExe) { string folder = Aurora_ConfigDir; MakeSureExists(folder + "Grid/ServerConfiguration/Login.ini"); IniConfigSource login_ini = new IniConfigSource(folder + "Grid/ServerConfiguration/Login.ini", Nini.Ini.IniFileType.AuroraStyle); IniConfigSource login_ini_example = new IniConfigSource(folder + "Grid/ServerConfiguration/Login.ini.example", Nini.Ini.IniFileType.AuroraStyle); foreach (IConfig config in login_ini_example.Configs) { IConfig newConfig = login_ini.AddConfig(config.Name); foreach (string key in config.GetKeys()) { if (key == "WelcomeMessage") { newConfig.Set(key, welcomeMessage); } else if (key == "AllowAnonymousLogin") { newConfig.Set(key, allowAnonLogin); } else { newConfig.Set(key, config.Get(key)); } } } login_ini.Save(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Your Login.ini has been successfully configured"); Console.ResetColor(); MakeSureExists(folder + "Grid/ServerConfiguration/GridInfoService.ini"); IniConfigSource grid_info_ini = new IniConfigSource(folder + "Grid/ServerConfiguration/GridInfoService.ini", Nini.Ini.IniFileType.AuroraStyle); IConfig conf = grid_info_ini.AddConfig("GridInfoService"); conf.Set("GridInfoInHandlerPort", 8002); conf.Set("login", "http://" + gridIPAddress + ":8002"); conf.Set("gridname", gridName); conf.Set("gridnick", gridName); grid_info_ini.Save(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Your GridInfoService.ini has been successfully configured"); Console.ResetColor(); } Console.WriteLine("\n====================================================================\n"); Console.ResetColor(); Console.WriteLine("Your grid name is "); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine(gridName); Console.ResetColor(); if (isStandalone) { Console.WriteLine("\nYour loginuri is "); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("http://" + gridIPAddress + (isAuroraExe ? ":9000/" : ":8002/")); Console.ResetColor(); } else { Console.WriteLine("\nConnected Grid URL: "); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("http://" + gridIPAddress + ":8002/"); Console.ResetColor(); } Console.WriteLine("\n====================================================================\n"); Console.WriteLine( "If you ever want to rerun this configurator, you can type \"run configurator\" into the console to bring this prompt back up."); } } }
public void parseIniFile() { if (fileExists(path)) { IConfigSource source = new IniConfigSource(path); if (source.Configs["Gestures"].GetInt("Minimum time", GESTURE_MIN_TIME) < 0 || source.Configs["Gestures"].GetInt("Minimum time", GESTURE_MIN_TIME) > 5000) { source.Configs["Gestures"].Set("Minimum time", GESTURE_MIN_TIME); } if (source.Configs["Gestures"].GetDouble("Minimum confidence", GESTURE_MIN_CONFIDENCE) < 0 || source.Configs["Gestures"].GetDouble("Minimum confidence", GESTURE_MIN_CONFIDENCE) > 1) { source.Configs["Gestures"].Set("Minimum confidence", GESTURE_MIN_CONFIDENCE); } if (source.Configs["Gestures"].Get("path", GESTURE_PATH).CompareTo("null") == 0 && !fileExists(source.Configs["Gestures"].Get("path", GESTURE_PATH))) { source.Configs["Gestures"].Set("path", "null"); } if (source.Configs["Drawing"].GetInt("Line thickness", LINE_THICKNESS) < 5 || source.Configs["Drawing"].GetInt("Line thickness", LINE_THICKNESS) > 100) { source.Configs["Drawing"].Set("Line thickness", LINE_THICKNESS); } if (source.Configs["Drawing"].GetInt("Resume threshold", LINE_RESUME_THRESHOLD) < 0 || source.Configs["Drawing"].GetInt("Resume threshold", LINE_RESUME_THRESHOLD) > 200) { source.Configs["Drawing"].Set("Resume threshold", LINE_RESUME_THRESHOLD); } if (source.Configs["Drawing"].GetInt("Freehand straight minimum distance", LINE_FREEHAND_STRAIGHT_MIN_DIST) < 0 || source.Configs["Drawing"].GetInt("Freehand straight minimum distance", LINE_FREEHAND_STRAIGHT_MIN_DIST) > 99) { source.Configs["Drawing"].Set("Freehand straight minimum distance", LINE_FREEHAND_STRAIGHT_MIN_DIST); } if (source.Configs["Drawing"].GetInt("Freehand straight angle", LINE_FREEHAND_STRAIGHT_ANGLE) < 0 || source.Configs["Drawing"].GetInt("Freehand straight angle", LINE_FREEHAND_STRAIGHT_ANGLE) > 90) { source.Configs["Drawing"].Set("Freehand straight angle", LINE_FREEHAND_STRAIGHT_ANGLE); } if (source.Configs["Drawing"].GetDouble("Smoothing", SMOOTHING) < 0 || source.Configs["Drawing"].GetDouble("Smoothing", SMOOTHING) > 0.999) { source.Configs["Drawing"].Set("Smoothing", SMOOTHING); } if (source.Configs["Drawing"].GetInt("Rubber size", RUBBER_SIZE) < 0 || source.Configs["Drawing"].GetInt("Rubber size", RUBBER_SIZE) > 200) { source.Configs["Drawing"].Set("Rubber size", RUBBER_SIZE); } if (source.Configs["Drawing"].GetInt("Minimum time between user action", USER_ACTION_MIN_TIME) < 0 || source.Configs["Drawing"].GetInt("Minimum time between user action", USER_ACTION_MIN_TIME) > 1000) { source.Configs["Drawing"].Set("Minimum time between user action", USER_ACTION_MIN_TIME); } source.Save(); GESTURE_MIN_TIME = source.Configs["Gestures"].GetInt("Minimum time", GESTURE_MIN_TIME); GESTURE_MIN_CONFIDENCE = source.Configs["Gestures"].GetDouble("Minimum confidence", GESTURE_MIN_CONFIDENCE); LINE_THICKNESS = source.Configs["Drawing"].GetInt("Line thickness", LINE_THICKNESS); LINE_RESUME_THRESHOLD = source.Configs["Drawing"].GetInt("Resume threshold", LINE_RESUME_THRESHOLD); LINE_FREEHAND_STRAIGHT_MIN_DIST = source.Configs["Drawing"].GetInt("Freehand straight minimum distance", LINE_FREEHAND_STRAIGHT_MIN_DIST); LINE_FREEHAND_STRAIGHT_ANGLE = source.Configs["Drawing"].GetInt("Freehand straight angle", LINE_FREEHAND_STRAIGHT_ANGLE); SMOOTHING = source.Configs["Drawing"].GetDouble("Smoothing", SMOOTHING); RUBBER_SIZE = source.Configs["Drawing"].GetInt("Rubber size", RUBBER_SIZE); USER_ACTION_MIN_TIME = source.Configs["Drawing"].GetInt("Minimum time between user action", USER_ACTION_MIN_TIME); if (source.Configs["Gestures"].Get("draw hand state") != null && source.Configs["Gestures"].Get("rubber hand state") != null && source.Configs["Gestures"].Get("move hand state") != null) { if (source.Configs["Gestures"].Get("draw hand state").CompareTo(HandState.Lasso.ToString()) == 0) { GESTURE_DRAW = HandState.Lasso; } else if (source.Configs["Gestures"].Get("rubber hand state").CompareTo(HandState.Lasso.ToString()) == 0) { GESTURE_RUBBER = HandState.Lasso; } else if (source.Configs["Gestures"].Get("move hand state").CompareTo(HandState.Lasso.ToString()) == 0) { GESTURE_MOVE = HandState.Lasso; } if (source.Configs["Gestures"].Get("draw hand state").CompareTo(HandState.Open.ToString()) == 0) { GESTURE_DRAW = HandState.Open; } else if (source.Configs["Gestures"].Get("rubber hand state").CompareTo(HandState.Open.ToString()) == 0) { GESTURE_RUBBER = HandState.Open; } else if (source.Configs["Gestures"].Get("move hand state").CompareTo(HandState.Open.ToString()) == 0) { GESTURE_MOVE = HandState.Open; } if (source.Configs["Gestures"].Get("draw hand state").CompareTo(HandState.Closed.ToString()) == 0) { GESTURE_DRAW = HandState.Closed; } else if (source.Configs["Gestures"].Get("rubber hand state").CompareTo(HandState.Closed.ToString()) == 0) { GESTURE_RUBBER = HandState.Closed; } else if (source.Configs["Gestures"].Get("move hand state").CompareTo(HandState.Closed.ToString()) == 0) { GESTURE_MOVE = HandState.Closed; } } } else { System.IO.File.Create(@path).Close(); IConfigSource source = new IniConfigSource("UserConfig.ini"); IConfig config = source.AddConfig("Gestures"); config.Set("Minimum time", GESTURE_MIN_TIME); config.Set("Minimum confidence", GESTURE_MIN_CONFIDENCE); config.Set("draw hand state", GESTURE_DRAW.ToString()); config.Set("rubber hand state", GESTURE_RUBBER.ToString()); config.Set("move hand state", GESTURE_MOVE.ToString()); config = source.AddConfig("Drawing"); config.Set("Line thickness", LINE_THICKNESS); config.Set("Resume threshold", LINE_RESUME_THRESHOLD); config.Set("Freehand straight minimum distance", LINE_FREEHAND_STRAIGHT_MIN_DIST); config.Set("Freehand straight angle", LINE_FREEHAND_STRAIGHT_ANGLE); config.Set("Smoothing", SMOOTHING); config.Set("Rubber size", RUBBER_SIZE); config.Set("Minimum time between user action", USER_ACTION_MIN_TIME); source.Save(); } }
public static void Play() { if (File.Exists(Program.madcowINI)) { try { IConfigSource source = new IniConfigSource(Program.madcowINI); String Src = source.Configs["DiabloPath"].Get("D3Path"); if (ProcessFinder.FindProcess("Mooege") == false) { if (File.Exists(Compile.currentMooegeExePath)) { Console.WriteLine("Starting Mooege.."); Process Mooege = new Process(); Mooege.StartInfo = new ProcessStartInfo(Compile.currentMooegeExePath); Mooege.Start(); Thread.Sleep(3000); //We sleep so our ErrorFinder has time to parse Mooege logs. if (ErrorFinder.SearchLogs("Fatal") == true) { Console.WriteLine("Closing Mooege due Fatal Exception"); ProcessFinder.KillProcess("Mooege"); } else { Console.WriteLine("Starting Diablo.."); Process Diablo3 = new Process(); Diablo3.StartInfo = new ProcessStartInfo(Src); Diablo3.StartInfo.Arguments = " -launch -auroraaddress localhost:1345"; Diablo3.Start(); //We save this repository for LastPlayed function. source.Configs["LastPlay"].Set("Repository", Compile.currentMooegeExePath); source.Save(); Process D3Patcher = new Process(); D3Patcher.StartInfo = new ProcessStartInfo(Program.programPath + @"\BnetPatcher\Bnet.Patcher.exe"); D3Patcher.Start(); } } else { Console.WriteLine("[Error] Couldn't find selected repository binaries." + "\nTry updating the repository again."); } } else //If Mooege is running we kill it and start it again. { Console.WriteLine("Killing Mooege Process.."); ProcessFinder.KillProcess("Mooege"); Console.WriteLine("Starting Mooege.."); Process Mooege = new Process(); Mooege.StartInfo = new ProcessStartInfo(Compile.currentMooegeExePath); Mooege.Start(); Thread.Sleep(3000); if (ErrorFinder.SearchLogs("Fatal") == true) { Console.WriteLine("Closing Mooege due Fatal Exception"); ProcessFinder.KillProcess("Mooege"); } else { Console.WriteLine("Starting Diablo.."); Process Diablo3 = new Process(); Diablo3.StartInfo = new ProcessStartInfo(Src); Diablo3.StartInfo.Arguments = " -launch -auroraaddress localhost:1345"; Diablo3.Start(); //We save this repository for LastPlayed function. source.Configs["LastPlay"].Set("Repository", Compile.currentMooegeExePath); source.Save(); Process D3Patcher = new Process(); D3Patcher.StartInfo = new ProcessStartInfo(Program.programPath + @"\BnetPatcher\Bnet.Patcher.exe"); D3Patcher.Start(); } } } catch { Console.WriteLine("[ERROR] Could not launch Diablo. (Diablo.cs)" + "\nPlease report this error in the forum."); } } //If madcow.ini aint found. else { Console.WriteLine("[ERROR] Could not find MadCow config file. (Diablo.cs)" + "\nPlease report this error in the forum."); } }
public ConfigurationLoader(string masterConfigLocation, string overridesConfigLocation) { #region Overrides File Creation // Create the user config include file if it doesn't exist to // prevent a warning message at startup try { string userConfigPath = GetConfigPath(SIMIAN_CONFIG_USER_FILE); if (!File.Exists(userConfigPath)) { using (FileStream stream = File.Create(userConfigPath)) { } } } catch { } #endregion Overrides File Creation #region MIME Type File string mimeConfigPath = GetConfigPath(MIME_TYPE_CONFIG_FILE); // Load and parse the MIME type file try { string[] mimeLines = File.ReadAllLines(mimeConfigPath); char[] splitChars = new char[] { ' ', '\t' }; for (int i = 0; i < mimeLines.Length; i++) { string line = mimeLines[i].Trim(); if (!String.IsNullOrEmpty(line) && line[0] != '#') { string[] parts = line.Split(splitChars, StringSplitOptions.RemoveEmptyEntries); if (parts.Length > 1) { string mimeType = parts[0]; m_typesToExtensions[mimeType] = parts[1]; for (int j = 1; j < parts.Length; j++) { m_extensionsToTypes[parts[j]] = mimeType; } } } } } catch (Exception ex) { m_log.Error("Failed to load MIME types from " + mimeConfigPath + ": " + ex.Message); } #endregion MIME Type File // Load the master ini file IniConfigSource masterConfig = LoadConfig(GetConfigPath(masterConfigLocation)); // Load the overrides ini file IniConfigSource overridesConfig = LoadConfig(GetConfigPath(overridesConfigLocation)); // Merge masterConfig.Merge(overridesConfig); // Save the merged config file in-memory so we can make copies later using (MemoryStream stream = new MemoryStream()) { masterConfig.Save(stream); m_configData = stream.ToArray(); } }
/// <summary> /// Save config /// </summary> public void Save(string path) { m_config.Save(path); }