public ReadFile ( string filePath ) : IniParser.IniData | ||
filePath | string | /// Path to the file /// |
return | IniParser.IniData |
public void check_parses_real_test_files() { var parser = new FileIniDataParser(); parser.Parser.Configuration.ThrowExceptionsOnError = true; var iniFileData = parser.ReadFile("aircraft.cfg"); parser.Parser.Configuration.CommentString = "//"; iniFileData = parser.ReadFile("aircraft2.cfg"); }
//constructor public ConfigHandler() { FileIniDataParser Parser = new FileIniDataParser(); string configDir = String.Format(@"{0}\config", GetLocalDir()); string configPath = String.Format(@"{0}\config\launcherConfig.ini", GetLocalDir()); //release 0.0. string defaultLauncherVersion = "0.0.3"; if (!Directory.Exists(configDir)) { Directory.CreateDirectory(configDir); } if (!File.Exists(configPath)) { //here we create a new empty file FileStream configStream = File.Create(configPath); configStream.Close(); //read the file as an INI file try { IniData data = Parser.ReadFile(configPath); data.Sections.AddSection("Local"); data.Sections.AddSection("Remote"); data.Sections.AddSection("Launchpad"); data["Local"].AddKey("launcherVersion", defaultLauncherVersion); data["Local"].AddKey("gameName", "Example"); data["Local"].AddKey("systemTarget", "Win64"); data["Remote"].AddKey("FTPUsername", "anonymous"); data["Remote"].AddKey("FTPPassword", "anonymous"); data["Remote"].AddKey("FTPUrl", "ftp://example.example.com"); data["Launchpad"].AddKey("bOfficialUpdates", "true"); Parser.WriteFile(configPath, data); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } else { IniData data = Parser.ReadFile(configPath); data["Local"]["launcherVersion"] = defaultLauncherVersion; Parser.WriteFile(configPath, data); } }
public static void Train() { FileIniDataParser parser = new FileIniDataParser(); IniData data = parser.ReadFile("config.ini"); for (int i = 1; i <= 4; i++) { string stringPosition = data["barracks"]["barrack" + i]; Point pointPosition = new Point(Convert.ToInt32(stringPosition.Split(';')[0]), Convert.ToInt32(stringPosition.Split(';')[1])); string stringTroop = data["troops"]["barrack" + i]; int intTroop = Convert.ToInt32(stringTroop); if(pointPosition.X != -1 || pointPosition.Y != -1) { Home.bsProcess.mouse.SendClick(WButton.Left, pointPosition, false); Thread.Sleep(1000); if (ColorDif.isCorrect(Home.bsProcess.image.GetPixelColor(Buttons.GetPos("5_5", Settings.xDif, Settings.yDif)), Color.FromArgb(112, 140, 176))) Home.bsProcess.mouse.SendClick(WButton.Left, Buttons.GetPos("5_5", Settings.xDif, Settings.yDif), false); else if(ColorDif.isCorrect(Home.bsProcess.image.GetPixelColor(Buttons.GetPos("3_3", Settings.xDif, Settings.yDif)), Color.FromArgb(161, 184, 207))) Home.bsProcess.mouse.SendClick(WButton.Left, Buttons.GetPos("3_3", Settings.xDif, Settings.yDif), false); else Home.bsProcess.mouse.SendClick(WButton.Left, Buttons.GetPos("4_4", Settings.xDif, Settings.yDif), false); Thread.Sleep(1000); while (!SameRGB(Home.bsProcess.image.GetPixelColor(CocFunctions.Buttons.GetPos("troop" + intTroop, Settings.xDif, Settings.yDif)))) { Home.bsProcess.mouse.SendClick(WButton.Left, CocFunctions.Buttons.GetPos("troop" + intTroop, Settings.xDif, Settings.yDif), false); Thread.Sleep(100); } Home.bsProcess.mouse.SendClick(WButton.Left, new Point(0,0), false); Thread.Sleep(500); } } Home.bsProcess.mouse.SendClick(WButton.Left, new Point(0, 0), false); }
public void programLoad() { { //load from config file FileIniDataParser parser = new FileIniDataParser(); IniData data = parser.ReadFile("resource/installer.ini"); {// set logo image var logoPath = data["GLOBAL"]["logo"]; string logoClean = String.Format("resource/{0}", logoPath); Console.WriteLine("ini file claims logo image is {0}", logoClean); FileInfo fi = new FileInfo(logoClean); long logoSize = (fi.Length / 1024); Console.WriteLine("Loaded logo ({0}KB)", logoSize); this.logo.ImageLocation = logoClean; fi = null; //destroy FileInfo } {//figure out what to install var toInstall = data["GLOBAL"]["file"]; var where = data["GLOBAL"]["destination"]; Console.WriteLine("ini file claims {0} is going to be installed to {1}", toInstall, where); } {//set readme docs this.readmedocs = new Uri(data["GLOBAL"]["readme"], UriKind.Absolute); Console.WriteLine("ini file claims readme docs are located {0}", this.readmedocs); } {//set start page text this.startText = data["GLOBAL"]["startpage"].Replace("{break}",Environment.NewLine); Console.WriteLine("loaded start text from ini file"); } } }
public static String GetConnectionString(String AppID) { FileIniDataParser i = new FileIniDataParser(); i.Parser.Configuration.CommentString = "#"; IniData data = i.ReadFile(Settings.Preferences.GetConfig()); bool decrypt = false; if (Convert.ToBoolean(data["HOST"]["Encrypt"])) { decrypt = true; } String myConnectionString = ""; if (decrypt) { myConnectionString = String.Format("server={0};uid={1}; pwd={2}; port={3}; database={4};", data["HOST"]["IP"], data["HOST"]["User"], MySQLSet.Decrypt(data["HOST"]["Pass"]), data["HOST"]["Port"], data["DS"][AppID]); } else { myConnectionString = String.Format("server={0};uid={1}; pwd={2}; port={3}; database={4};", data["HOST"]["IP"], data["HOST"]["User"], data["HOST"]["Pass"], data["HOST"]["Port"], data["DS"][AppID]); } return myConnectionString; }
public static void Load() { List.Clear(); foreach (var item in Directory.GetFiles(Global.Folder.Profile, "*.ifp")) { var parser = new FileIniDataParser(); IniData data = parser.ReadFile(item); var p = new Profile(); p.File = item; p.Info.Format = data["info"]["format"]; p.Info.Platform = data["info"]["platform"]; p.Info.Name = data["info"]["name"]; p.Info.Author = data["info"]["author"]; p.Info.Web = data["info"]["web"]; p.Picture.Resolution = data["picture"]["resolution"]; p.Picture.FrameRate = data["picture"]["framerate"]; p.Picture.BitDepth = Convert.ToInt32(data["picture"]["bitdepth"]); p.Picture.Chroma = Convert.ToInt32(data["picture"]["chroma"]); p.Video.Preset = data["video"]["preset"]; p.Video.Tune = data["video"]["tune"]; p.Video.Type = Convert.ToInt32(data["video"]["type"]); p.Video.Value = data["video"]["value"]; p.Video.Command = data["video"]["cmd"]; p.Audio.Encoder = data["audio"]["encoder"]; p.Audio.BitRate = data["audio"]["bitrate"]; p.Audio.Freq = data["audio"]["frequency"]; p.Audio.Chan = data["audio"]["channel"]; p.Audio.Args = data["audio"]["cmd"]; List.Add(p); } }
private void LoadConfiguration() { if (!File.Exists(Environment.CurrentDirectory + "\\KeyboardExtender.cfg")) { CreateDefaultConfigFile(); } FileIniDataParser finiParser = new IniParser.FileIniDataParser(); IniData envelope = finiParser.ReadFile(Environment.CurrentDirectory + "\\KeyboardExtender.cfg"); string modmask = envelope["General"]["ModMask"]; this._modifierArray = CalculateModifierArrayFromString(modmask); List <KeyData> keys = envelope["Keys"].ToList(); foreach (KeyData key in keys) { string keyRaw = key.KeyName; string value = key.Value; foreach (var bind in this._availableBindings) { if (bind.Identifier == value) { bind.TriggerKey = (Keys)Enum.Parse(typeof(Keys), keyRaw); bind.ModifierArray = this._modifierArray; this._activeBindings.Add(bind); } } } }
public static bool IsTroopsReady() { FileIniDataParser parser = new FileIniDataParser(); IniData data = parser.ReadFile("config.ini"); string stringPosition = data["barracks"]["barrack1"]; Point pointPosition = new Point(Convert.ToInt32(stringPosition.Split(';')[0]), Convert.ToInt32(stringPosition.Split(';')[1])); if (pointPosition.X != -1 || pointPosition.Y != -1) { Home.bsProcess.mouse.SendClick(WButton.Left, pointPosition, false); Thread.Sleep(500); if (ColorDif.isCorrect(Home.bsProcess.image.GetPixelColor(Buttons.GetPos("5_5", Settings.xDif, Settings.yDif)), Color.FromArgb(112, 140, 176))) Home.bsProcess.mouse.SendClick(WButton.Left, Buttons.GetPos("5_5", Settings.xDif, Settings.yDif), false); else Home.bsProcess.mouse.SendClick(WButton.Left, Buttons.GetPos("4_4", Settings.xDif, Settings.yDif), false); Thread.Sleep(500); if (ColorDif.isCorrect(Home.bsProcess.image.GetPixelColor(Buttons.GetPos("troop_ready", Settings.xDif, Settings.yDif)), Color.FromArgb(216, 72, 81))) { Home.bsProcess.mouse.SendClick(WButton.Left, new Point(0, 0), false); Thread.Sleep(500); Home.bsProcess.mouse.SendClick(WButton.Left, new Point(0, 0), false); return true; } } Home.bsProcess.mouse.SendClick(WButton.Left, new Point(0, 0), false); Thread.Sleep(500); Home.bsProcess.mouse.SendClick(WButton.Left, new Point(0, 0), false); return false; }
private string ReadIniFileByDirectory(string _field1, string _field2) { IniParser.FileIniDataParser sss = new IniParser.FileIniDataParser(); IniData data = sss.ReadFile("config.ini", ASCIIEncoding.Default); string needData = data[_field1][_field2]; return(needData); }
/// <summary> /// Initializes a new instance of the <see cref="MonoDevelop.WakaTime.WakaTimeConfigFile"/> class. /// </summary> static WakaTimeConfigFile() { _configParser = new FileIniDataParser(); _configFilepath = GetConfigFilePath(); _configData = (File.Exists(_configFilepath)) ? _configParser.ReadFile(_configFilepath, new UTF8Encoding(false)) : new IniData(); Read(); }
private void change_Click(object sender, EventArgs e) { var parser = new FileIniDataParser(); var data = parser.ReadFile("DefaultService.ini"); data["KR_REAL"]["AUTH_DOMAIN"] = ip1.Text; File.Delete("DefaultService.ini"); parser.WriteFile("DefaultService.ini", data); serverIP.Text = ip1.Text; serverIP.ForeColor = Color.Red; data = parser.ReadFile("service.ini"); data["KR"]["AUTHENTIC_DOMAIN"] = ip2.Text; File.Delete("service.ini"); parser.WriteFile("service.ini", data); authip.Text = ip2.Text; authip.ForeColor = Color.Red; }
private void GetOPCReadAddress() { IniParser.FileIniDataParser sss = new IniParser.FileIniDataParser(); IniData data = sss.ReadFile("config.ini", ASCIIEncoding.Default); foreach (var dd in data["OPCRead"]) { OPC_Read_Address.Add(dd.Value); } }
private void defaultip_Click(object sender, EventArgs e) { var parser = new FileIniDataParser(); var data = parser.ReadFile("DefaultService.ini"); data["KR_REAL"]["AUTH_DOMAIN"] = "auth.black.game.daum.net"; File.Delete("DefaultService.ini"); parser.WriteFile("DefaultService.ini", data); serverIP.Text = @"auth.black.game.daum.net"; serverIP.ForeColor = Color.Green; data = parser.ReadFile("service.ini"); data["KR"]["AUTHENTIC_DOMAIN"] = "blackauth.black.game.daum.net"; File.Delete("service.ini"); parser.WriteFile("service.ini", data); authip.Text = @"blackauth.black.game.daum.net"; authip.ForeColor = Color.Green; }
public void check_parse_unicode_chinese_characters() { var parser = new FileIniDataParser(); parser.Parser.Configuration.ThrowExceptionsOnError = true; var iniFileData = parser.ReadFile("unicode_chinese.ini"); // If you want to write the file you must specify the encoding //parser.WriteFile("unicode_chinese_copy.ini", iniFileData, Encoding.UTF8); }
public static IniData GetData() { FileIniDataParser i = new FileIniDataParser(); i.Parser.Configuration.CommentString = "#"; IniData data = i.ReadFile(GetConfig()); return data; }
public void test_multiple_file_encodings() { var parser = new FileIniDataParser(); // Encoding.Default is now the default value used in the ReadFile method, but is // specified in this call for consistency with the issue report IniData parsedData = parser.ReadFile("./Issue18_example.ini", Encoding.UTF8); Assert.That(parsedData.Sections.ContainsSection("Identität")); Assert.That(parsedData.Sections["Identität"]["key"], Is.EqualTo("value")); }
public Settings() { var settingsFile = Path.Combine(BasePath, "config.ini"); if (!File.Exists(settingsFile)) { Logger.Log(String.Format("Settings file {0} does not exist. Creating default file.", settingsFile), Logger.LogType.Warn, typeof(Settings)); using (File.Create(settingsFile)) { } } Logger.Log(String.Format("Loading settings from {0}", settingsFile), typeof(Settings)); _parser = new FileIniDataParser(); _ini = _parser.ReadFile(settingsFile); LoadSettings(); }
public static void Collect() { FileIniDataParser parser = new FileIniDataParser(); IniData data = parser.ReadFile("config.ini"); for (int i = 1; i <= 17; i++) { string stringPosition = data["collectors"]["collector" + i]; Point pointPosition = new Point(Convert.ToInt32(stringPosition.Split(';')[0]), Convert.ToInt32(stringPosition.Split(';')[1])); if (pointPosition.X != -1 && pointPosition.Y != -1) Home.bsProcess.mouse.SendClick(WButton.Left, pointPosition, false); Thread.Sleep(250); } Home.bsProcess.mouse.SendClick(WButton.Left, new Point(0, 0), false); }
private void SaveBtn_Click(object sender, EventArgs e) { FileIniDataParser i = new FileIniDataParser(); i.Parser.Configuration.CommentString = "#"; IniData data = i.ReadFile(Preferences.GetConfig()); data["DS"][AppID] = NewDbName.Text; retText = NewDbName.Text; i.WriteFile(Preferences.GetConfig(), data); DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); }
private IniFile() { Data = new IniData(); // If ini file is not present, then just exit. if (!System.IO.File.Exists(IniFile.IniFileName)) { return; } // Else parse the data. var iniParser = new FileIniDataParser(); Data = iniParser.ReadFile(IniFileName); }
public Tuple<SemanticVersion, string> Load(DllReference parentAssembly, string Dependency) { var path = parentAssembly.Id.Item1 + _sectionSeparator + parentAssembly.Id.Item2 + _sectionSeparator + Dependency + ".ini"; if (!File.Exists(@"cache\" + path)) return null; var parser = new FileIniDataParser(); var iniData = parser.ReadFile(@"cache\" + path); var section = iniData.Sections["Dependency"]; var version = SemanticVersion.ParseOptionalVersion(section["version"]); var name = section["name"]; return new Tuple<SemanticVersion, string>(version, name); }
private void Form1_Load(object sender, EventArgs e) { var parser = new IniParser.FileIniDataParser(); var data = parser.ReadFile(settingFileName); //読み込み parameter.Path = data["Settings"]["Path"]; string rules = data["Settings"]["Rules"]; parameter.Rules = rules.Split(',').ToList(); parameter.Rules.RemoveAll(x => x.Length == 0); textBox1.Text = parameter.Path; listBox1.Items.AddRange(parameter.Rules.ToArray()); }
public static CommandDescription[] GetCommands(string file) { List<CommandDescription> commands = new List<CommandDescription>(); FileIniDataParser parser = new FileIniDataParser(); parser.Parser.Configuration.CommentString = "#"; if (File.Exists (file)) { IniData config = parser.ReadFile (file); foreach (SectionData section in config.Sections) { string command = section.SectionName; string command_args = string.Empty; string description_small = string.Empty; string description_Long = string.Empty; User.PermissionLevel permission = User.PermissionLevel.Server; string callback = string.Empty; if (config [command].ContainsKey ("command_args")) { command_args = config [command] ["command_args"]; } if (config [command].ContainsKey ("description_small")) { description_small = config [command] ["description_small"]; } else { Logger.LogError ("Failed to parse Command \"" + command + "\": Short description not specified."); } if (config [command].ContainsKey ("description_Long")) { description_Long = config [command] ["description_Long"]; } if (config[command].ContainsKey("permission")) { string permissionStr = config[command]["permission"]; User.PermissionLevel tmpPerm; if (Enum.TryParse(permissionStr, true, out tmpPerm)) permission = tmpPerm; } if (config [command].ContainsKey ("function")) { callback = config [command] ["function"]; } else { Logger.LogError ("Failed to parse Command \"" + command + "\": Function not specified."); } commands.Add (new CommandDescription (command, command_args, description_small, description_Long, permission, callback)); } } else Logger.LogError("Command file not found."); return commands.ToArray(); }
public void Load(string path, bool clean) { SARAH.GetInstance().Log("ConfigManager", "Loading: " + path); var parser = new FileIniDataParser(); var conf = parser.ReadFile(path); //SARAH.GetInstance().Log("ConfigManager", conf.ToString()); if (clean) { foreach (var section in conf.Sections) { section.LeadingComments.Clear(); section.TrailingComments.Clear(); foreach (var keydata in section.Keys) { keydata.Comments.Clear(); } } } if (Config == null) { Config = conf; } else { Config.Merge(conf); } }
/// <summary> /// Initialises a new instance of the <see cref="ScriptManifest"/> class with the /// specified manifest file name. /// </summary> /// <param name="manifestFile">Manifest file name</param> public ScriptManifest(string manifestFile) { const string cixScriptSection = "CIXReader Script"; string manifestFolder = Path.GetDirectoryName(manifestFile) ?? "."; FileIniDataParser parser = new FileIniDataParser(); IniData data = parser.ReadFile(manifestFile); bool tempValue; Name = data[cixScriptSection]["Name"]; Description = data[cixScriptSection]["Description"]; ScriptFile = data[cixScriptSection]["Script"]; IconFile = Path.Combine(manifestFolder, data[cixScriptSection]["Icon"]); InstallToToolbar = Boolean.TryParse(data[cixScriptSection]["Toolbar"], out tempValue) && tempValue; Author = data[cixScriptSection]["Author"]; }
private bool SaveLibFromINI() { var parser = new IniParser.FileIniDataParser(); IniData data = parser.ReadFile("Lib2.ini"); foreach (SectionData section in data.Sections) { var book = new Books(); book.ISBN = section.SectionName; book.Title = data[section.SectionName]["Title"]; book.Author = data[section.SectionName]["Author"]; book.PublicationDate = data[section.SectionName]["PublicationDate"]; book.Annotation = data[section.SectionName]["Annotation"]; books.Add(book); } return(true); }
private void Form1_FormClosed(object sender, FormClosedEventArgs e) { var parser = new IniParser.FileIniDataParser(); var data = parser.ReadFile(settingFileName); //書き込み data["Settings"]["Path"] = parameter.Path; string rules = ""; foreach (var str in parameter.Rules) { rules += str + ","; } data["Settings"]["Rules"] = rules; parser.WriteFile(settingFileName, data); }
public static void Main() { //Create an instance of a ini file parser FileIniDataParser fileIniData = new FileIniDataParser(); if (File.Exists("NewTestIniFile.ini")) File.Delete("NewTestIniFile.ini"); // This is a special ini file where we use the '#' character for comment lines // instead of ';' so we need to change the configuration of the parser: fileIniData.Parser.Configuration.CommentString = "#"; //Parse the ini file IniData parsedData = fileIniData.ReadFile("TestIniFile.ini"); //Write down the contents of the ini file to the console Console.WriteLine("---- Printing contents of the INI file ----\n"); Console.WriteLine(parsedData); Console.WriteLine(); //Get concrete data from the ini file Console.WriteLine("---- Printing setMaxErrors value from GeneralConfiguration section ----"); Console.WriteLine("setMaxErrors = " + parsedData["GeneralConfiguration"]["setMaxErrors"]); Console.WriteLine(); //Modify the INI contents and save Console.WriteLine(); // Modify the loaded ini file IniData modifiedParsedData = ModifyINIData(parsedData); //Write down the contents of the modified ini file to the console Console.WriteLine("---- Printing contents of the new INI file ----"); Console.WriteLine(modifiedParsedData); Console.WriteLine(); //Save to a file Console.WriteLine("---- Saving the new ini file to the file NewTestIniFile.ini ----"); Console.WriteLine(); // Uncomment this to change the new line string used to write the ini file to disk to // force use the windows style new line //modifiedParsedData.Configuration.NewLineStr = "\r\n"; fileIniData.WriteFile("NewTestIniFile.ini", modifiedParsedData); }
public static void Locate() { FileIniDataParser parser = new FileIniDataParser(); IniData data = parser.ReadFile("config.ini"); for (int i = 1; i <= 17; i++) { if (MessageBox.Show("Please set the cursor on your collector number " + i + " and press enter. Click on cancel if not available", "Collectors localization", MessageBoxButtons.OKCancel) == DialogResult.OK) { Point collectorPos = FindCursorPos(); data["collectors"]["collector" + i] = collectorPos.X + ";" + collectorPos.Y; Home.bsProcess.mouse.SendClick(WButton.Left, collectorPos, false); } else data["collectors"]["collector" + i] = "-1;-1"; } parser.WriteFile("config.ini", data); Home.bsProcess.mouse.SendClick(WButton.Left, new Point(0,0), false); }
public GameScene(CCWindow window) : base(window) { Id = ""; _backgroundLayer = new BackgroundLayer(); AddChild(_backgroundLayer); var cameraVisibleBounds = new CCSize(Settings.ScreenWidth, Settings.ScreenHeight); var camera = new CCCamera(CCCameraProjection.Projection3D, cameraVisibleBounds, new CCPoint3(Settings.ScreenWidth, Settings.ScreenHeight, 10)); GameLayer = new GameLayer { Tag = Tags.Client, Camera = camera, }; AddChild(GameLayer); _chatLayer = new ChatLayer(); AddChild(_chatLayer); _hudLayer = new HudLayer(); AddChild(_hudLayer); var keyListener = new CCEventListenerKeyboard {OnKeyPressed = OnKeyPressed, OnKeyReleased = OnKeyReleased}; AddEventListener(keyListener, this); var mouseListener = new CCEventListenerMouse { OnMouseDown = OnMouseDown, OnMouseUp = OnMouseUp, OnMouseMove = OnMouseScroll }; AddEventListener(mouseListener, this); var parser = new FileIniDataParser(); IniData data = parser.ReadFile("Config.ini"); string nickname = data["Client"]["nickname"]; _netGameClient = new NetGameClient(data["Server"]["ip"], this); _netGameClient.ConnectToServer(nickname); InitEvents(); Schedule(Update); Schedule(UpdateNetwork, Settings.NetworkFreqUpdate); }
private bool WriteBookToINI() { var parser = new IniParser.FileIniDataParser(); IniData data = parser.ReadFile("Library.ini"); foreach (var book in books) { //Add a new selection and some keys data.Sections.AddSection(book.ISBN); data[book.ISBN].AddKey("Author", book.Author); data[book.ISBN].AddKey("Title", book.Title); //data[book.ISBN].AddKey("PublicationDate", book.PublicationDate.ToString("d")); data[book.ISBN].AddKey("PublicationDate", book.PublicationDate); data[book.ISBN].AddKey("Annotation", book.Annotation); parser.WriteFile("Library.ini", data); } return(true); }
private static bool CompareResources(int fgold, int felixir, int fdark, int ftrophy) { bool good = true; FileIniDataParser parser = new FileIniDataParser(); IniData data = parser.ReadFile("config.ini"); bool bgold = Convert.ToBoolean(data["search"]["bgold"]); bool belixir = Convert.ToBoolean(data["search"]["belixir"]); bool bdark = Convert.ToBoolean(data["search"]["bdark"]); bool btrophy = Convert.ToBoolean(data["search"]["btrophy"]); int wgold = Convert.ToInt32(data["search"]["gold"]); int welixir = Convert.ToInt32(data["search"]["elixir"]); int wdark = Convert.ToInt32(data["search"]["dark"]); int wtrophy = Convert.ToInt32(data["search"]["trophy"]); if (bgold && fgold < wgold) good = false; if (belixir && felixir < welixir) good = false; if (bdark && fdark < wdark) good = false; if (btrophy && ftrophy < wtrophy) good = false; return good; }
IniParser.Model.IniData getIniParserConfigInjectionTextures() { IniParser.Model.IniData parsedIniData = null; // Attempt to load configInjectionTextures.ini string userIniPathConfigInjectionTextures = Path.Combine(Application.dataPath, iniPathConfigInjectionTextures); if (File.Exists(userIniPathConfigInjectionTextures)) { parsedIniData = iniParser.ReadFile(userIniPathConfigInjectionTextures); } // Load fallback configInjectionTextures .ini TextAsset asset = Resources.Load <TextAsset>(iniPathFallbackConfigInjectionTextures); if (asset != null) { MemoryStream stream = new MemoryStream(asset.bytes); StreamReader reader = new StreamReader(stream); parsedIniData = iniParser.ReadData(reader); reader.Close(); } return(parsedIniData); }
void LangCreate() { var parser = new FileIniDataParser(); IniData data = parser.ReadFile(Path.Combine(Global.Folder.Language, "en.ini")); data.Sections[Name].AddKey("title", Text); data.Sections.AddSection(Name); Control ctrl = this; do { ctrl = GetNextControl(ctrl, true); if (ctrl != null) if (ctrl is Label || ctrl is Button || ctrl is TabPage || ctrl is CheckBox || ctrl is RadioButton || ctrl is GroupBox) if (!string.IsNullOrEmpty(ctrl.Text)) data.Sections[Name].AddKey(ctrl.Name, ctrl.Text.Replace("\n", "\\n").Replace("\r", "")); } while (ctrl != null); data.Sections[Name].AddKey($"VisitWeb", "Visit &Website"); foreach (ColumnHeader item in lstPlugin.Columns) data.Sections[Name].AddKey($"{item.Tag}", item.Text); foreach (ColumnHeader item in lstExtension.Columns) data.Sections[Name].AddKey($"{item.Tag}", item.Text); foreach (ColumnHeader item in lstProfile.Columns) data.Sections[Name].AddKey($"{item.Tag}", item.Text); data.Sections[Name].AddKey("Installed", Language.Installed); data.Sections[Name].AddKey("NotInstalled", Language.NotInstalled); parser.WriteFile(Path.Combine(Global.Folder.Language, "en.ini"), data); }
/// <summary> /// /// </summary> public static void LoadSetting() { var parser = new FileIniDataParser(); SettingData = parser.ReadFile("../../Setting.ini", Encoding.UTF8); }
public Form1() { InitializeComponent(); //Create an instance of a ini file parser parser = new FileIniDataParser(); parser.Parser.Configuration.CommentString = "#"; String configINI = Environment.CurrentDirectory + "\\config.ini"; parsedData = parser.ReadFile(configINI); //This line gets the SectionData from the section "global" KeyDataCollection keyCol = parsedData["global"]; numerJezdni = keyCol["numerJezdni"]; kierunek = keyCol["kierunek"]; pasRuchu = keyCol["pasRuchu"]; kategoriaDrogi = keyCol["kategoriaDrogi"]; picturesPath = keyCol["picturesPath"]; makroPath = keyCol["makroPath"]; powiat = keyCol["powiat"]; gmina = keyCol["gmina"]; if (Directory.Exists(Environment.CurrentDirectory + "\\Headers")) { String[] headerFiles = Directory.GetFiles(Environment.CurrentDirectory + "\\Headers", "*.xml"); foreach(String headerPath in headerFiles){ if (headerPath.ToLower().Contains("tp1a")) { tp1aHeader = new XmlDocument(); tp1aHeader.Load(headerPath); } else if (headerPath.ToLower().Contains("tp1b")) { tp1bHeader = new XmlDocument(); tp1bHeader.Load(headerPath); } else if (headerPath.ToLower().Contains("tp3")) { tp3Header = new XmlDocument(); tp3Header.Load(headerPath); } else if(headerPath.ToLower().Contains("foto")) { fotoHeader = new XmlDocument(); fotoHeader.Load(headerPath); } } } bool sqliteExist = checkSQLite(); if (!sqliteExist) { createDatabaseSqlite(); createTables(sqlCon); } else { if (sqlCon == null || sqlCon.State != ConnectionState.Open) { sqlCon = SetConnection(); } SQLiteCommand cmd = sqlCon.CreateCommand(); cmd.CommandText = "SELECT count(*) FROM dane"; int count = Convert.ToInt32(cmd.ExecuteScalar()); if(count !=0){ richTextBox1.SelectionFont = new Font(richTextBox1.SelectionFont, FontStyle.Bold); richTextBox1.AppendText("SQLite database exist and contains data."+Environment.NewLine); } else { richTextBox1.SelectionFont = new Font(richTextBox1.SelectionFont, FontStyle.Bold); richTextBox1.AppendText("SQLite database exist with no data." + Environment.NewLine); } } if (Directory.Exists(Environment.CurrentDirectory + "\\xsd")) { String[] filesXSD = Directory.GetFiles(Environment.CurrentDirectory + "\\xsd"); if (filesXSD != null && filesXSD.Length != 0) { schemaDSN = new XmlSchemaSet(); schemaDSN.Add("http://www.gddkia.gov.pl/dsn/1.0.0", Environment.CurrentDirectory + "\\xsd\\dane_elementarne.xsd"); schemaGML = new XmlSchemaSet(); schemaGML.Add("http://www.opengis.net/gml", Environment.CurrentDirectory + "\\xsd\\gml\\gmlProfileDSN.xsd"); richTextBox1.SelectionFont = new Font(richTextBox1.SelectionFont, FontStyle.Bold); richTextBox1.AppendText("XSD Schema loaded." + Environment.NewLine); } else { richTextBox1.SelectionFont = new Font(richTextBox1.SelectionFont, FontStyle.Bold); richTextBox1.AppendText("XSD Schema is not present." + Environment.NewLine); } } }
/// <summary> /// Replaces and updates the old pre-unix config. /// </summary> /// <returns><c>true</c>, if an old config was copied over to the new format, <c>false</c> otherwise.</returns> private bool UpdateOldConfig() { string oldConfigPath = String.Format(@"{0}config{1}launcherConfig.ini", GetLocalDir(), Path.DirectorySeparatorChar); string oldConfigDir = String.Format(@"{0}config", GetLocalDir()); if (ChecksHandler.IsRunningOnUnix()) { //Case sensitive //Is there an old config file? if (File.Exists(oldConfigPath)) { lock (ReadLock) { //Have we not already created the new config dir? if (!Directory.Exists(GetConfigDir())) { //if not, create it. Directory.CreateDirectory(GetConfigDir()); //Copy the old config file to the new location. File.Copy(oldConfigPath, GetConfigPath()); //read our new file. FileIniDataParser Parser = new FileIniDataParser(); IniData data = Parser.ReadFile(GetConfigPath()); //replace the old invalid keys with new, updated keys. string launcherVersion = data["Local"]["launcherVersion"]; string gameName = data["Local"]["gameName"]; string systemTarget = data["Local"]["systemTarget"]; data["Local"].RemoveKey("launcherVersion"); data["Local"].RemoveKey("gameName"); data["Local"].RemoveKey("systemTarget"); data["Local"].AddKey("LauncherVersion", launcherVersion); data["Local"].AddKey("GameName", gameName); data["Local"].AddKey("SystemTarget", systemTarget); WriteConfig (Parser, data); //We were successful, so return true. File.Delete(oldConfigPath); Directory.Delete(oldConfigDir, true); return true; } else { //The new config dir already exists, so we'll just toss out the old one. //Delete the old config File.Delete(oldConfigPath); Directory.Delete(oldConfigDir, true); return false; } } } else { return false; } } else { lock (ReadLock) { //Windows is not case sensitive, so we'll use direct access without copying. if (File.Exists(oldConfigPath)) { FileIniDataParser Parser = new FileIniDataParser(); IniData data = Parser.ReadFile(GetConfigPath()); //replace the old invalid keys with new, updated keys. string launcherVersion = data["Local"]["launcherVersion"]; string gameName = data["Local"]["gameName"]; string systemTarget = data["Local"]["systemTarget"]; data["Local"].RemoveKey("launcherVersion"); data["Local"].RemoveKey("gameName"); data["Local"].RemoveKey("systemTarget"); data["Local"].AddKey("LauncherVersion", launcherVersion); data["Local"].AddKey("GameName", gameName); data["Local"].AddKey("SystemTarget", systemTarget); WriteConfig (Parser, data); //We were successful, so return true. return true; } else { return false; } } } }
/// <summary> /// Sets the system target. /// </summary> /// <param name="SystemTarget">System target.</param> public void SetSystemTarget(ESystemTarget SystemTarget) { //possible values are: //Win64 //Win32 //Linux //Mac lock (ReadLock) { try { FileIniDataParser Parser = new FileIniDataParser(); IniData data = Parser.ReadFile(GetConfigPath()); data["Local"]["SystemTarget"] = SystemTarget.ToString(); WriteConfig(Parser, data); } catch (IOException ioex) { Console.WriteLine("IOException in SetSystemTarget(): " + ioex.Message); } } }