public FileConfigurationStore(IList<string> filePaths) { if (filePaths == null || filePaths.Count == 0 || !filePaths.All(c => !String.IsNullOrWhiteSpace(c))) throw new ArgumentNullException("filePaths", "The parameter filePaths cannot be empty or contains empty string"); this.fileIniDataParser = new FileIniDataParser(); this.fileIniDataParser.Parser.Configuration.CommentString = "#"; this.filePaths = filePaths; }
static void Main(string[] args) { Console.WriteLine("Reading Generation Info File \n"); FileIniDataParser parser = new FileIniDataParser(); IniData genData = parser.LoadFile("generation.ini"); Console.WriteLine("Generation Info File Read \n"); foreach (SectionData genSection in genData.Sections) { Console.WriteLine(String.Format("Analyzing {0} \n", genSection.SectionName)); Console.WriteLine(String.Format("=============================================== \n", genSection.SectionName)); GenerationInfo info = new GenerationInfo(); info.CompanyName = genSection.Keys["companyname"].Replace(";", ""); info.DataNameSpace = genSection.Keys["datanamespace"].Replace(";", ""); info.FolderPath = genSection.Keys["path"].Replace(";", ""); info.ServerName = genSection.Keys["server"].Replace(";", ""); info.DataBase = genSection.Keys["database"].Replace(";", ""); MGenerator.Tools.Generator.GenerateFromDatabase(info); Console.WriteLine(String.Format("=============================================== \n", genSection.SectionName)); Console.WriteLine(String.Format("done \n", genSection.SectionName)); Console.WriteLine(String.Format("=============================================== \n", genSection.SectionName)); } Console.Write("Press any key to continue . . . "); Console.ReadKey(true); }
public static void CreateDefault() { //Create ini file FileIniDataParser parser = new FileIniDataParser(); IniData data = new IniData(); //Add global section data.Sections.AddSection("game"); //Add global settings data["game"]["hidemode"] = "1"; //Add collectors section data.Sections.AddSection("collectors"); //Add collectors locations for (int i = 1; i <= 17; i++) { data["collectors"]["collector" + i] = "-1:-1"; } //Add troops section data.Sections.AddSection("troops"); //Add troops settings for (int i = 1; i <= 4; i++) { data["troops"]["barrack" + i] = "0"; } //Add search section data.Sections.AddSection("search"); //Add search settings data["search"]["gold"] = "50000"; data["search"]["elixir"] = "50000"; data["search"]["dark"] = "0"; data["search"]["trophy"] = "0"; data["search"]["bgold"] = "1"; data["search"]["belixir"] = "1"; data["search"]["bdark"] = "0"; data["search"]["btrophy"] = "0"; data["search"]["alert"] = "0"; //Add attack section data.Sections.AddSection("attack"); //Add attack settings data["attack"]["topleft"] = "True"; data["attack"]["topright"] = "True"; data["attack"]["bottomleft"] = "True"; data["attack"]["bottomright"] = "True"; data["attack"]["mode"] = "0"; data["attack"]["maxtrophy"] = "1000"; data["attack"]["bmaxtrophy"] = "False"; data["attack"]["deploytime"] = "75"; //Save the file parser.WriteFile(AppSettings.Cfg.FilePath, 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); }
/// <summary> /// Parses the boards. /// </summary> /// <returns>The boards.</returns> /// <param name="Path">Path.</param> public static Board[] ParseBoards(StreamReader Path) { var Parser = new IniParser.FileIniDataParser(); IniData Data = Parser.ReadData(Path); var Boards = new System.Collections.Generic.List <Board> (); foreach (SectionData sd in Data.Sections) { try { Boards.Add(new Board() { Name = sd.Keys.GetKeyData("Name").Value, NumberOfAnalogPins = Convert.ToUInt32(sd.Keys.GetKeyData("NumberOfAnalogPins").Value), NumberOfDigitalPins = Convert.ToUInt32(sd.Keys.GetKeyData("NumberOfDigitalPins").Value), MCU = sd.Keys.GetKeyData("MCU").Value, ImageFilePath = sd.Keys.GetKeyData("ImagePath").Value, SDA = ConfigHelper.StringToArray(sd.Keys.GetKeyData("SDA").Value), SCL = ConfigHelper.StringToArray(sd.Keys.GetKeyData("SCL").Value), RX = ConfigHelper.StringToArray(sd.Keys.GetKeyData("RX").Value), TX = ConfigHelper.StringToArray(sd.Keys.GetKeyData("TX").Value), UseDTR = Convert.ToBoolean(sd.Keys.GetKeyData("DTR").Value), HardwareAnalogPins = ConfigHelper.StringToArray(sd.Keys.GetKeyData("HWAPinsAddrs").Value), AnalogReferences = ConfigHelper.StringToARefDict(sd.Keys.GetKeyData("AREF").Value), PinLayout = ConfigHelper.StringToLayout(sd.Keys.GetKeyData("PinLeft").Value, sd.Keys.GetKeyData("PinRight").Value, sd.Keys.GetKeyData("PinBottom").Value), PinLocation = ConfigHelper.StringToPinPlacement(sd.Keys.GetKeyData("PinPosition").Value) }); } catch (Exception ex) { Console.WriteLine(ex); } } return(Boards.ToArray()); }
static void Main(string[] args) { string server_ini_file = @"Ini\servers.ini"; C("HTTP Server Starting"); if (File.Exists(server_ini_file)) { C("Using File {0} for configuration", server_ini_file); FileIniDataParser parser = new FileIniDataParser(); var servers = parser.LoadFile(server_ini_file); servers.Sections .ToList() .ForEach(server_config => { NSServer server = new NSServer(server_config.Keys["listenon"], Int32.Parse(server_config.Keys["port"]), "/"); server.CreateHttpServer(); C("Starting Server {0} : listening on http://{1}:{2}/", server_config.SectionName, server_config.Keys["listenon"], server_config.Keys["port"]); }); C("Servers have been started."); } Console.WriteLine("Waiting..."); Console.Read(); }
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 Main() { //Create an instance of a ini file parser FileIniDataParser fileIniData = new FileIniDataParser(); if (File.Exists("NewTestIniFile.ini")) File.Delete("NewTestIniFile.ini"); //Parse the ini file IniData parsedData = fileIniData.LoadFile("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.ToString()); //Get concrete data from the ini file Console.WriteLine("---- Printing contents concrete data from the INI file ----"); Console.WriteLine("setMaxErrors = " + parsedData["GeneralConfiguration"]["setMaxErrors"]); Console.WriteLine(); //Modify the INI contents and save Console.WriteLine(); //Write down the contents of the modified ini file to the console Console.WriteLine("---- Printing contents of the new INI file ----\n"); IniData modifiedParsedData = ModifyINIData(parsedData); Console.WriteLine(modifiedParsedData.ToString()); //Save to a file fileIniData.SaveFile("NewTestIniFile.ini", modifiedParsedData); }
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 Form1_Load(object sender, EventArgs e) { if (!File.Exists("DefaultService.ini") || !File.Exists("service.ini") || !File.Exists("version.dat") || !File.Exists("bin/BlackDesert32.exe") || !File.Exists("bin64/BlackDesert64.exe") ) { MessageBox.Show(@"Invalid Launcher location.", @"Error!"); Application.Exit(); return; } var parser = new FileIniDataParser(); var data = parser.ReadFile("DefaultService.ini"); var serverIp1 = data["KR_REAL"]["AUTH_DOMAIN"]; var data2 = parser.ReadFile("service.ini"); var serverIp2 = data2["KR"]["AUTHENTIC_DOMAIN"]; serverIP.Text = serverIp1; authip.Text = serverIp2; serverIP.ForeColor = serverIp1 == "auth.black.game.daum.net" ? Color.Green : Color.Red; authip.ForeColor = serverIp2 == "blackauth.black.game.daum.net" ? Color.Green : Color.Red; }
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; }
List<Report> getReports() { if (reports == null) { reports = new List<Report>(); var dir = new DirectoryInfo(GraphPkgInfo.ReportsDir); foreach (var reportDir in dir.GetDirectories()) { // parse the ini and create the report object var parser = new FileIniDataParser(); var infoTxtPath = Path.Combine(reportDir.FullName, "info.txt"); if (File.Exists(infoTxtPath) == false) continue; var infoData = parser.LoadFile(infoTxtPath, relaxedIniRead: true); var report = new Report { Key = reportDir.Name, Name = getInfoData(infoData, "Name"), Description = getInfoData(infoData, "Description"), ReportDir = reportDir.FullName }; report.ThemeFile = getInfoData(infoData, "Theme", report.ThemeFile); report.TemplateFile = getInfoData(infoData, "Template", report.TemplateFile); report.ScriptFile = getInfoData(infoData, "Script", report.ScriptFile); report.TemplateLayoutFile = getInfoData(infoData, "TemplateLayout", report.TemplateLayoutFile); reports.Add(report); } } return reports; }
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 void allow_duplicated_sections() { FileIniDataParser parser = new FileIniDataParser(); IniData parsedData = parser.LoadFile("Issue11_example.ini"); Assert.That(parsedData.Global[".reg (Win)"], Is.EqualTo("notepad.exe")); }
public void Issue11_Tests() { FileIniDataParser parser = new FileIniDataParser(); IniData parsedData = parser.LoadFile("Issue11_example.ini",true); Assert.That(parsedData.Global[".reg (Win)"], Is.EqualTo("notepad.exe")); }
private Config(string path) { FilePath = path; FileHandler = new FileIniDataParser(); ConfigHandler = FileHandler.LoadFile(path); //Fill Dictionary ReplacingData.Add("$(root)",Global.AppDir); }
public static void Display() { foreach (var item in Directory.GetFiles(Global.Folder.Language, "*.ini")) { var data = new FileIniDataParser().ReadFile(item, Encoding.UTF8); Lists.Add(new Language() { Code = data["info"]["Code"], Name = data["info"]["Name"] }); } }
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); }
public main() { IniParser.FileIniDataParser parser = new FileIniDataParser(); IniData parsedData = parser.LoadFile("setting/ui-setting.ini"); rubyPath = parsedData["PATH"]["ruby"]; compassPath = parsedData["PATH"]["compass"]; dirListPath = parsedData["PATH"]["dirlist"]; frameworkPath = parsedData["PATH"]["framework"]; /// components = new System.ComponentModel.Container(); this.contextMenu1 = new System.Windows.Forms.ContextMenu(); this.menuItem0 = new System.Windows.Forms.MenuItem(); this.menuItem1 = new System.Windows.Forms.MenuItem(); // Initialize contextMenu1 this.contextMenu1.MenuItems.AddRange( new System.Windows.Forms.MenuItem[] { this.menuItem0,this.menuItem1 }); // Initialize menuItem1 this.menuItem1.Index = 1; this.menuItem1.Text = "E&xit"; this.menuItem1.Click += new System.EventHandler(this.exitWindowHander); this.menuItem0.Index = 0; this.menuItem0.Text = "H&ide"; this.menuItem0.Click += new System.EventHandler(this.showWindowHander); // Set up how the form should be displayed. this.ClientSize = new System.Drawing.Size(292, 266); this.Text = "Compass Bundle UI"; // Create the NotifyIcon. this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components); // The Icon property sets the icon that will appear // in the systray for this application. notifyIcon1.Icon = new Icon(Directory.GetCurrentDirectory()+"/icon/compass_icon.ico"); // The ContextMenu property sets the menu that will // appear when the systray icon is right clicked. notifyIcon1.ContextMenu = this.contextMenu1; // The Text property sets the text that will be displayed, // in a tooltip, when the mouse hovers over the systray icon. notifyIcon1.Text = "Compass Bundle UI"; notifyIcon1.Visible = true; // Handle the DoubleClick event to activate the form. notifyIcon1.DoubleClick += new System.EventHandler(this.notifyIcon1_DoubleClick); //MessageBox.Show(compassBatPath); InitializeComponent(); this.loadList(); this.add2CLI("load the default folder list."); this.write2Xml(); this.initCreateList(); this.Show(); }
/// <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 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); } }
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 WampServer(string path) { rootPath = path; FileIniDataParser parser = new FileIniDataParser(); IniData data = parser.LoadFile(Path.Combine(path, "wampmanager.conf")); string version = data["apache"]["apacheVersion"]; apacheVersion = version.Trim('"', '\''); this.ApacheConfigPath = Path.Combine(path, "alias\\"); this.ServerRootPath = Path.Combine(path, "www"); }
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"); }
public confForm() { IniParser.FileIniDataParser parser = new FileIniDataParser(); IniData parsedData = parser.LoadFile("d:/tmp/compass-bundle/ui-setting.ini"); compassBatPath = parsedData["PATH"]["compass_bat"]; dirListPath = parsedData["PATH"]["dirlist"]; InitializeComponent(); txtCompassBatPath.Text = compassBatPath; txtPathListPath.Text = dirListPath; }
//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 void Issue17_Tests() { FileIniDataParser parser = new FileIniDataParser(); IniData parsedData = parser.LoadFile("Issue17_example.ini"); Assert.That(parsedData.Sections.Count, Is.EqualTo(1)); Assert.That(parsedData.Sections.ContainsSection("{E3729302-74D1-11D3-B43A-00AA00CAD128}"), Is.True); Assert.That(parsedData.Sections["{E3729302-74D1-11D3-B43A-00AA00CAD128}"].ContainsKey("key"), Is.True); Assert.That(parsedData.Sections["{E3729302-74D1-11D3-B43A-00AA00CAD128}"]["key"], Is.EqualTo("value")); }
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")); }
protected static void Main(string[] args) { DateTime buildDate = new System.IO.FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).LastWriteTime; string buildDateStr = buildDate.ToString("G"); Console.Title = "EO Proxy"; Console.WriteLine("EO Proxy =-= Build : " + System.Diagnostics.FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).FileVersion + " (" + buildDateStr + ")\n"); Console.WriteLine(); Console.WriteLine("Loading Configs\n\n"); IniParser.FileIniDataParser parser = new FileIniDataParser(); parser.CommentDelimiter = '#'; IniData settings = parser.LoadFile("config.ini"); AuthAddress = settings["IP"]["AuthAddress"]; ProxyAddress = settings["IP"]["ProxyAddress"]; Console.WriteLine("Connecting to the Authentication server on: " + AuthAddress); Console.WriteLine("Proxy is redirecting game server connects to: " + ProxyAddress); ConsoleLogging = Convert.ToBoolean(settings["Options"]["ConsoleLogging"]); DebugMode = Convert.ToBoolean(settings["Options"]["DebugMode"]); WriteToBytes = Convert.ToBoolean(settings["Options"]["WriteToBytes"]); PacketSniffingPath = settings["Options"]["PacketLocation"]; Console.WriteLine("\nPackets will be saved to: " + PacketSniffingPath); Console.WriteLine("\nAll Settings Loaded.\n\n\n"); Console.WriteLine("Preparing Connections...\n"); KeyValuePair<ushort, ushort>[] bindings = new KeyValuePair<ushort,ushort>[2]; bindings[0] = new KeyValuePair<ushort, ushort>(4444, 9958); // Again, here are the ports that the client bindings[1] = new KeyValuePair<ushort, ushort>(4445, 9959); // can use to connect. Make sure that yours is foreach (KeyValuePair<ushort, ushort> bindpair in bindings) { Console.WriteLine(" Launching AuthServer [" + bindpair.Value + "] on " + bindpair.Key + "..."); var server = new AsyncSocket(bindpair.Key, bindpair.Value); server.ClientConnect += new Action<AsyncWrapper>(accountServer_ClientConnect); // This is initializing the socket server.ClientReceive += new Action<AsyncWrapper, byte[]>(accountServer_ClientReceive); // system... basic Async. This is server.ClientDisconnect += new Action<object>(accountServer_ClientDisconnect); // for each auth port. server.Listen(); } Console.WriteLine(" Launching GameServer [5816] on 4446..."); var gameServer = new AsyncSocket(WorldPort, 5816); gameServer.ClientConnect += new Action<AsyncWrapper>(gameServer_ClientConnect); // This is the game server's socket gameServer.ClientReceive += new Action<AsyncWrapper, byte[]>(gameServer_ClientReceive); // system. Notice the actions... right gameServer.ClientDisconnect += new Action<object>(gameServer_ClientDisconnect); // click them and say "Go to definition". gameServer.Listen(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("\nProxy is online.\n"); Console.ForegroundColor = ConsoleColor.White; while (true) Console.ReadLine(); }
/// <summary> /// EN: Constructor of class to create instance and set path to save file /// </summary> /// <param name="filePath">Path to file</param> /// <example>Example: how to create instance</example> /// <code>IniWriter("folder/filename.ini")</code> public IniWriter(string filePath) { if (filePath != null) { path = filePath; if (data == null) { data = new IniData(); } parser = new FileIniDataParser(); } }
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(); }
internal IniData Load(string path) { parser = new FileIniDataParser(); IniData data = new IniData(); try { data = parser.LoadFile(path); } catch (ParsingException e) { throw e.InnerException; } return data; }
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()); }
static MasterServerClient CreateMasterServerClient(GameServer server) { IniData data = null; try { IniParser.FileIniDataParser parser = new IniParser.FileIniDataParser(); data = parser.LoadFile("GameServer.ini"); } catch (System.Exception ex) { Logger.Error(ex.Message); } return(new MasterServerClient(server, GetValue(data, "Master", "GUID", "none"))); }
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); }
static GameServer CreateServer() { IniData data = null; try { IniParser.FileIniDataParser parser = new IniParser.FileIniDataParser(); data = parser.LoadFile("GameServer.ini"); } catch (System.Exception ex) { Logger.Error(ex.Message); } return(new GameServer( GetValue(data, "General", "Name", "Default server name"), GetValue(data, "General", "Port", 14242))); }
public static HashFile OpenFile(string filePath) { if (System.IO.File.Exists(filePath)) { System.IO.File.Delete(filePath); } using (var newFile = System.IO.File.Create(filePath)) { newFile.Flush(); } IniParser.FileIniDataParser parser = new IniParser.FileIniDataParser(); var iniData = parser.LoadFile(filePath); return(new HashFile(iniData) { FileName = filePath }); }
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); }
protected void Save(string filePath, IniData iniData) { IniParser.FileIniDataParser parser = new IniParser.FileIniDataParser(); parser.SaveFile(filePath, iniData); }
/// <summary> /// Writes the config data to disk. This method is thread-blocking, and all write operations /// are synchronized via lock(WriteLock). /// </summary> /// <param name="Parser">The parser dealing with the current data.</param> /// <param name="Data">The data which should be written to file.</param> private void WriteConfig(FileIniDataParser Parser, IniData Data) { lock (WriteLock) { Parser.WriteFile (GetConfigPath (), Data); } }