Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
        static ArrayList readFilter(string mode, string eventlog, string filter = "")
        {
            // array to store filters
            ArrayList filters = new ArrayList();
            // get filename for filters
            string filterFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, mode, eventlog + ".conf");

            Program.log.Debug(String.Format("Read filter file \"{0}\"", filterFile));
            if (!File.Exists(filterFile))
            {
                Program.readFilterError = (String.Format("File not found '{0}'.", filterFile));
                return(filters);
            }
            // read INI-file
            IniParser.FileIniDataParser iniParser = new FileIniDataParser();
            iniParser.KeyValueDelimiter = ':';
            iniParser.CommentDelimiter  = '#';
            IniData iniData = null;

            try
            {
                iniData = iniParser.LoadFile(filterFile);
            }
            catch (Exception ex)
            {
                Program.readFilterError = String.Format("Cannot read file '{0}'. {1}", filterFile, ex);
                return(filters);
            }
            if (!String.IsNullOrWhiteSpace(filter))
            {
                try
                {
                    if (String.IsNullOrWhiteSpace(iniData["General"][filter]))
                    {
                        Program.readFilterError = String.Format("Filter '{0}' not found in '{1}'.", filter, filterFile);
                        return(filters);
                    }
                    filters.Add("(" + iniData["General"][filter] + ")");
                    Program.log.Debug(String.Format("Use filter '{0}' : {1}", filter, iniData["General"][filter]));
                }
                catch (Exception ex)
                {
                    Program.readFilterError = String.Format("Cannot read filter '{0}' in '{1}'. {2}", filter, filterFile, ex);
                    return(filters);
                }
            }
            else
            {
                foreach (KeyData key in iniData.Sections["General"])
                {
                    filters.Add("(" + key.Value + ")");
                    Program.log.Debug(String.Format("Use filter '{0}' = {1}", key.KeyName, key.Value));
                }
                if (filters.Count < 1)
                {
                    Program.readFilterError = "Filters empty.";
                }
            }
            return(filters);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        private void tts8888WebBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (tts8888WebBrowser.ReadyState == WebBrowserReadyState.Complete)
            {
                return;
            }

            FileIniDataParser parser     = new FileIniDataParser();
            IniData           parserData = parser.LoadFile("C:/test.ini");

            KeyDataCollection Keycol      = parserData["Info"];
            string            iniUsername = Keycol["user"];
            string            iniPassWord = Keycol["pass"];

            HtmlWindow windows      = tts8888WebBrowser.Document.Window;
            var        inputTagName = windows.Document.GetElementsByTagName("input");

            if (inputTagName.Count == 3)
            {
                if (inputTagName[0] == null || inputTagName[1] == null || inputTagName[2] == null)
                {
                    return;
                }
                else
                {
                    inputTagName[0].SetAttribute("value", iniUsername);
                    inputTagName[2].SetAttribute("value", iniPassWord);
                    inputTagName[1].InvokeMember("click");
                }
            }
        }
Ejemplo n.º 6
0
        public static SectionDataCollection GetSectsFromCfg(string file)
        {
            FileIniDataParser parser = new FileIniDataParser();
            IniData           data   = parser.LoadFile(file);

            return(data.Sections);
        }
Ejemplo n.º 7
0
        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"));
        }
Ejemplo n.º 8
0
        private string GetEmuleAdunanzAConfiguredUdpPort()
        {
            //Create an instance of a ini file parser
            IniParser.FileIniDataParser iniparser = new FileIniDataParser();

            IniData data = iniparser.LoadFile(GetEmuleAdunanzAConfigPath());

            return(data["eMule"]["UDPPort"]);
        }
Ejemplo n.º 9
0
        private void SetEmuleAdunanzAUdpPort(int port)
        {
            if ((port > 65554) && (port == 0))
            {
                throw new Exception("la Porta UDP da configurare non e' valida");
            }

            //Create an instance of a ini file parser
            IniParser.FileIniDataParser iniparser = new FileIniDataParser();

            IniData data = iniparser.LoadFile(GetEmuleAdunanzAConfigPath());

            data["eMule"]["UDPPort"] = port.ToString();
        }
Ejemplo n.º 10
0
        public string ReadConfig(string type, string key)
        {
            var ini = new FileIniDataParser();

            try
            {
                var parsedData = ini.LoadFile(AppDomain.CurrentDomain.BaseDirectory + @"config.ini");
                return(parsedData[type][key]);
            }
            catch
            {
                // ignored
            }
            return(null);
        }
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Return sectioned key/value pair loaded from the ini-file.
        /// </summary>
        /// <param name="iniFile">File name</param>
        /// <returns></returns>
        public static Dictionary <string, Dictionary <string, object> > LoadIni(string iniFile)
        {
            var result = new Dictionary <string, Dictionary <string, object> >();
            var parser = new FileIniDataParser();
            var data   = parser.LoadFile(iniFile);

            foreach (var section in data.Sections)
            {
                result.Add(section.SectionName, new Dictionary <string, object>());
                foreach (var key in section.Keys)
                {
                    result[section.SectionName].Add(key.KeyName, key.Value);
                }
            }
            return(result);
        }
Ejemplo n.º 13
0
        private void Initialize()
        {
            var parser = new FileIniDataParser();
            var data   = parser.LoadFile("config.ini");

            _host     = data["database"]["hostname"];
            _database = data["database"]["database"];
            _username = data["database"]["user"];
            _password = data["database"]["password"];
            _port     = data["database"]["port"];

            var conString = string.Format(
                "SERVER={0};PORT={1};DATABASE={2};UID={3};PASSWORD={4};",
                _host, _port, _database, _username, _password);

            _connection = new MySqlConnection(conString);
        }
Ejemplo n.º 14
0
        Configuration()
        {
            string settingsFile = Path.Combine(FileHelper.GetSettingsDirectory(), "Settings.ini");

            _parser       = new FileIniDataParser();
            availableTabs = new List <string>();

            if (File.Exists(settingsFile))
            {
                _data = _parser.LoadFile(settingsFile);
            }
            else
            {
                _data = CreateDefault(settingsFile);
                Save();
            }
        }
Ejemplo n.º 15
0
        private static AnyDVDDiscInf GetAnyDVDDiscInf(Disc disc)
        {
            var discInf = disc.FileSystem.Files.AnyDVDDiscInf;

            if (discInf == null)
            {
                return(null);
            }
            var parser        = new FileIniDataParser();
            var data          = parser.LoadFile(discInf.FullName);
            var discData      = data["disc"];
            var anyDVDDiscInf = new AnyDVDDiscInf
            {
                AnyDVDVersion = discData["version"],
                VolumeLabel   = discData["label"],
                Region        = RegionCodeParser.Parse(discData["region"])
            };

            return(anyDVDDiscInf);
        }
Ejemplo n.º 16
0
 public void loadSettings()
 {
     if (!File.Exists(storageFile))
     {
         logger.debug("Ini file not found");
         return;
     }
     parsedData = parser.LoadFile(storageFile);
     foreach (SectionData section in parsedData.Sections)
     {
         if (section.SectionName.StartsWith("game:"))
         {
             gameEntry newGame = new gameEntry(section.Keys["exec"], section.Keys["name"]);
             if (section.Keys.ContainsKey("args"))
             {
                 newGame.runArgs = section.Keys["args"];
             }
             if (section.Keys.ContainsKey("execfolder"))
             {
                 newGame.execfolder = section.Keys["execfolder"];
             }
             if (section.Keys.ContainsKey("installFXfolder"))
             {
                 newGame.installFXfolder = section.Keys["installFXfolder"];
             }
             if (section.Keys.ContainsKey("execfolder"))
             {
                 newGame.execfolder = section.Keys["execfolder"];
             }
             if (section.Keys.ContainsKey("specialfolder"))
             {
                 newGame.special_folder = section.Keys["specialfolder"];
             }
             if (section.Keys.ContainsKey("special"))
             {
                 newGame.special_install = section.Keys["special"] == "1" ? true:false;
             }
             games.Add(newGame);
         }
     }
 }
Ejemplo n.º 17
0
        public TeamPilgrimSettings()
        {
            _parser = new FileIniDataParser();

            try
            {
                _iniData = _parser.LoadFile(GetSettingsFilePath);
            }
            catch (Exception)
            {
                _iniData = new IniData();
                SelectedWorkItemCheckinAction = SelectedWorkItemCheckinAction;
                PreviouslySelectedWorkItemQueriesValueSeperator = PreviouslySelectedWorkItemQueriesValueSeperator;
                PreviouslySelectedWorkItemQueriesMaxCount       = PreviouslySelectedWorkItemQueriesMaxCount;
                PreserveShelvedChangesLocally = PreserveShelvedChangesLocally;
                EvaluatePoliciesDuringShelve  = EvaluatePoliciesDuringShelve;
                Save();
            }

            PreviouslySelectedWorkItemsQueries = new PreviouslySelectedWorkItemsQueriesCollection(this);
        }
Ejemplo n.º 18
0
        public ProgramSettings(string iniFileName)
        {
            // is exists INI-file?
            Program.log.Debug(String.Format("Read INI File \"{0}\"", iniFileName));
            if (!File.Exists(iniFileName))
            {
                Program.log.Fatal("WinLogCheck stop: Cannot find INI File");
                Environment.Exit(2);
            }
            // read INI-file
            IniParser.FileIniDataParser iniParser = new FileIniDataParser();
            iniParser.CommentDelimiter = '#';
            IniData iniData = null;

            try
            {
                iniData = iniParser.LoadFile(iniFileName);
            }
            catch (Exception ex)
            {
                Program.log.Fatal("WinLogCheck stop: Cannot read INI File. " + ex);
                Environment.Exit(2);
            }
            // check report path and create it if not exists
            ReportPath = "";
            try
            {
                ReportPath = iniData["General"]["ReportPath"];
                if (String.IsNullOrWhiteSpace(ReportPath))
                {
                    ReportPath = "reports";
                }
                Program.log.Info(String.Format("Use directory \"{0}\" for temporary report.", ReportPath));
            }
            catch
            {
                ReportPath = "reports";
                Program.log.Info(String.Format("Use default directory \"{0}\" for temporary report.", ReportPath));
            }
            if (!Directory.Exists(ReportPath))
            {
                Program.log.Info(String.Format("Not exist directory \"{0}\". Create it.", ReportPath));
                try
                {
                    Directory.CreateDirectory(ReportPath);
                }
                catch (Exception ex)
                {
                    Program.log.Fatal(String.Format("WinLogCheck stop: Cannot create directory {0}. Stack: {1}", ReportPath, ex));
                    Environment.Exit(2);
                }
            }
            // check mail settings
            SMTP_Server = "";
            Mail_From   = "";
            Mail_To     = "";
            try
            {
                SMTP_Server = iniData["Mail"]["SMTP_Server"];
                Mail_From   = iniData["Mail"]["Mail_From"];
                Mail_To     = iniData["Mail"]["Mail_To"];
                if (String.IsNullOrWhiteSpace(SMTP_Server) || String.IsNullOrWhiteSpace(Mail_From) || String.IsNullOrWhiteSpace(Mail_To))
                {
                    SendReport = false;
                    Program.log.Warn("Check mail settings. Send summary report DISABLED");
                }
                else
                {
                    SendReport = true;
                    Program.log.Info("Send summary report ENABLED");
                }
            }
            catch
            {
                SendReport = false;
                Program.log.Warn("Check mail settings. Send summary report DISABLED");
            }
            ReportCSS = "";
            try
            {
                ReportCSS = iniData["General"]["ReportCSS"];
            }
            catch {}
            string sTimePeriod = "";

            try
            {
                sTimePeriod = iniData["General"]["TimePeriod"];
            }
            catch { }
            if (String.IsNullOrWhiteSpace(sTimePeriod))
            {
                TimePeriod = 24;
            }
            else
            {
                try
                {
                    TimePeriod = Convert.ToInt32(sTimePeriod);
                }
                catch
                {
                    TimePeriod = 24;
                }
            }
            Program.log.Info(String.Format("Get report for last {0} hours", TimePeriod.ToString()));
            WhereTime = DateTime.UtcNow.AddHours(-TimePeriod).ToString("yyyyMMdd HH:mm:ss");
        }
 /// <summary>
 /// Loads the specified ini file.
 /// </summary>
 /// <param name="filename">Full path to ini file.</param>
 /// <returns>True if successful.</returns>
 public void LoadFile(string filename)
 {
     ini           = parser.LoadFile(filename);
     this.filename = filename;
 }
Ejemplo n.º 20
0
        public void CheckParseEmptyFileSuccess()
        {
            IniData parsedData = iniParser.LoadFile(strEmptyINIFilePath);

            Assert.That(parsedData, Is.Not.Null);
        }
Ejemplo n.º 21
0
        public ProgramSettings(string iniFileName)
        {
            // is exists INI-file?
            Program.log.Debug(String.Format("Read INI File \"{0}\"", iniFileName));
            if (!File.Exists(iniFileName))
            {
                Program.log.Fatal("MSBPLaunch stop: Cannot find INI File");
                Environment.Exit(2);
            }
            // read INI-file
            IniParser.FileIniDataParser iniParser = new FileIniDataParser();
            IniData iniData = null;

            try
            {
                iniData = iniParser.LoadFile(iniFileName);
            }
            catch (Exception ex)
            {
                Program.log.Fatal("MSBPLaunch stop: Cannot read INI File. " + ex);
                Environment.Exit(2);
            }
            // check msbp.exe
            MsbpExe = "";
            try
            {
                MsbpExe = iniData["General"]["MsbpExe"];
                if (String.IsNullOrWhiteSpace(MsbpExe))
                {
                    Program.log.Fatal("MSBPLaunch stop: Not found path settings for msbp.exe");
                    Environment.Exit(2);
                }
            }
            catch
            {
                Program.log.Fatal("MSBPLaunch stop: Not found path settings for msbp.exe");
                Environment.Exit(2);
            }
            if (!File.Exists(MsbpExe))
            {
                Program.log.Fatal(String.Format("MSBPLaunch stop: Not found {0}", MsbpExe));
                Environment.Exit(2);
            }
            // check backup path and create it if not exists
            BackupPath = "";
            try
            {
                BackupPath = iniData["General"]["BackupPath"];
                if (String.IsNullOrWhiteSpace(BackupPath))
                {
                    Program.log.Fatal("MSBPLaunch stop: Not found path settings for backups");
                    Environment.Exit(2);
                }
            }
            catch
            {
                Program.log.Fatal("MSBPLaunch stop: Not found path settings for backups");
                Environment.Exit(2);
            }
            if (!Directory.Exists(BackupPath))
            {
                Program.log.Info(String.Format("Not exist directory \"{0}\". Create it.", BackupPath));
                try
                {
                    Directory.CreateDirectory(BackupPath);
                }
                catch (Exception ex)
                {
                    Program.log.Fatal(String.Format("MSBPLaunch stop: Cannot create directory {0}. Stack: {1}", BackupPath, ex));
                    Environment.Exit(2);
                }
            }
            // check mail settings
            SMTP_Server = "";
            Mail_From   = "";
            Mail_To     = "";
            try
            {
                SMTP_Server = iniData["Mail"]["SMTP_Server"];
                Mail_From   = iniData["Mail"]["Mail_From"];
                Mail_To     = iniData["Mail"]["Mail_To"];
                if (String.IsNullOrWhiteSpace(SMTP_Server) || String.IsNullOrWhiteSpace(Mail_From) || String.IsNullOrWhiteSpace(Mail_To))
                {
                    SendReport = false;
                    Program.log.Warn("Check mail settings. Send summary report DISABLED");
                }
                else
                {
                    SendReport = true;
                    Program.log.Info("Send summary report ENABLED");
                }
            }
            catch
            {
                SendReport = false;
                Program.log.Warn("Check mail settings. Send summary report DISABLED");
            }
            // set storage time
            StorageTime = new SortedList();
            try
            {
                StorageTime.Add("D", iniData["StorageTime"]["D"]);
                StorageTime.Add("W", iniData["StorageTime"]["W"]);
                StorageTime.Add("Q", iniData["StorageTime"]["Q"]);
            }
            catch
            {
                StorageTime.Add("D", 0);
                StorageTime.Add("W", 0);
                StorageTime.Add("Q", 0);
            }
            // get week of day a full backup
            string sWeeklyFullBackup = "";

            try
            {
                sWeeklyFullBackup = iniData["General"]["WeeklyFullBackup"];
            }
            catch {}
            if (String.IsNullOrWhiteSpace(sWeeklyFullBackup))
            {
                WeeklyFullBackup = 6;
            }
            else
            {
                try
                {
                    WeeklyFullBackup = Convert.ToInt32(sWeeklyFullBackup);
                }
                catch
                {
                    WeeklyFullBackup = 6;
                }
            }
            // get list a excluded databases
            ExcludeDB = "";
            try
            {
                string ExcludeTmp = iniData["General"]["ExcludeDB"];
                if (!String.IsNullOrWhiteSpace(ExcludeTmp))
                {
                    Array aExcuded = ExcludeTmp.Trim().Split(',');
                    int   i        = 0;
                    foreach (string s in aExcuded)
                    {
                        if (i > 0)
                        {
                            ExcludeDB = ExcludeDB + ",";
                        }
                        ExcludeDB = ExcludeDB + "'" + s.Trim() + "'";
                        i++;
                    }
                }
            }
            catch
            {
                ExcludeDB = "";
            }
            if (ExcludeDB.Length > 0)
            {
                Program.log.Info(String.Format("Excluded database: {0}", ExcludeDB));
            }
            else
            {
                Program.log.Info(String.Format("Excluded database: {0}", "NONE"));
            }
        }
Ejemplo n.º 22
0
        private void LoadSettings()
        {
            var parser = new FileIniDataParser();

            Settings = parser.LoadFile(AppDomain.CurrentDomain.BaseDirectory + @"\eAthena Studio.conf");
        }
Ejemplo n.º 23
0
        public void LoadFromIni()
        {
            string loc = Environment.CurrentDirectory + "\\Datas\\pokemons.ini";

            FileIniDataParser parser = new FileIniDataParser();
            IniData           ini    = parser.LoadFile(loc);

            for (int i = 1; i <= 649; i++)
            {
                KeyDataCollection section = ini.Sections["" + i];
                PokemonInfo       info    = new PokemonInfo(i);
                info.name         = iniValue(section, "Name");
                info.internalname = iniValue(section, "InternalName");
                info.type1        = PokeType.getTypeFromString(iniValue(section, "Type1"));
                info.type2        = PokeType.getTypeFromString(iniValue(section, "Type2"));

                //base stat parse
                string   basestats = iniValue(section, "BaseStats");
                string[] bsspl     = basestats.Split(',');
                int      _i        = 0;
                foreach (string _thres in bsspl)
                {
                    int val = Int32.Parse(_thres);
                    if (_i == 0)
                    {
                        info.hp = val;
                    }
                    else if (_i == 1)
                    {
                        info.attack = val;
                    }
                    else if (_i == 2)
                    {
                        info.spattack = val;
                    }
                    else if (_i == 3)
                    {
                        info.defence = val;
                    }
                    else if (_i == 4)
                    {
                        info.spdefence = val;
                    }
                    else if (_i == 5)
                    {
                        info.speed = val;
                    }
                    else
                    {
                        Console.WriteLine("what kind of f****d up shit is this");
                    }
                    _i++;
                }

                info.genderrate = new GenderRate();                 //todo
                info.xpcurve    = XpCurve.GetCurve(iniValue(section, "GrowthRate"));
                info.basexp     = Int32.Parse(iniValue(section, "BaseEXP"));

                //EV stat parse
                string   evyeld = iniValue(section, "BaseStats");
                string[] evspl  = evyeld.Split(',');
                int      j      = 0;
                foreach (string _thres in evspl)
                {
                    int val = Int32.Parse(_thres);
                    if (j == 0)
                    {
                        info.evhp = val;
                    }
                    else if (j == 1)
                    {
                        info.evattack = val;
                    }
                    else if (j == 2)
                    {
                        info.evspattack = val;
                    }
                    else if (j == 3)
                    {
                        info.evdefence = val;
                    }
                    else if (j == 4)
                    {
                        info.evspdefence = val;
                    }
                    else if (j == 5)
                    {
                        info.evspeed = val;
                    }
                    else
                    {
                        Console.WriteLine("what kind of f****d up shit is this");
                    }
                    j++;
                }

                info.rareness  = Int32.Parse(iniValue(section, "Rareness"));
                info.happiness = Int32.Parse(iniValue(section, "Happiness"));

                // --> ability here

                // --> hidden ability here

                string   learnset    = iniValue(section, "Moves");
                string[] learnsetspl = learnset.Split(',');
                int      k           = 0;
                int      cint        = -1;
                string   cstr        = "null";
                foreach (string _thres in learnsetspl)
                {
                    int w = k % 2;
                    if (w == 0)
                    {
                        cint = Int32.Parse(_thres);
                    }
                    else if (w == 1)
                    {
                        cstr = _thres;
                        info.learnablemoves.Add(new Tuple <int, string>(cint, cstr));
                    }

                    k++;
                }

                string   eggmoves    = iniValue(section, "EggMoves");
                string[] eggmovesspl = eggmoves.Split(',');
                info.eggmoves.AddRange(eggmovesspl);

                // --> compatibility

                info.hatch_steps = Int32.Parse(iniValue(section, "StepsToHatch"));
                info.height      = float.Parse(iniValue(section, "Height"), CultureInfo.InvariantCulture);
                info.weight      = float.Parse(iniValue(section, "Weight"), CultureInfo.InvariantCulture);
                info.color       = iniValue(section, "Color");
                info.habitat     = iniValue(section, "Habitat");
                //regional number
                info.kind             = iniValue(section, "Kind");
                info.pokedexentry     = iniValue(section, "Pokedex");
                info.battler_player_y = Int32.Parse(iniValue(section, "BattlerPlayerY"));
                info.battle_enemy_y   = Int32.Parse(iniValue(section, "BattlerEnemyY"));
                // --> altitude
                infos.Add(info);
            }
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Save sectioned data to ini-file
        /// </summary>
        /// <param name="fileName">File name</param>
        /// <param name="dict">key/value pair data</param>
        /// <param name="merge">if true - the data will be combined, old value will bee rewrite if some key </param>
        public static void SaveIni(string fileName, Dictionary <string, Dictionary <string, object> > dict, bool merge)
        {
            var parser = new FileIniDataParser();
            var data   = new IniData();

            if (!merge && File.Exists(fileName))
            {
                File.Delete(fileName);
            }
            else
            {
                data = parser.LoadFile(fileName);
            }
            foreach (var section in dict)
            {
                var sectionName = section.Key;
                if (!data.Sections.ContainsSection(sectionName))
                {
                    data.Sections.AddSection(sectionName);
                }
                var sectionData = section.Value;
                var sec         = data.Sections[sectionName];

                foreach (var keyVal in sectionData)
                {
                    if (!sec.ContainsKey(keyVal.Key))
                    {
                        sec.AddKey(keyVal.Key);
                    }
                    sec[keyVal.Key] = ValueToString(keyVal.Value);
                }
            }
            parser.SaveFile(fileName, data);

            /*var file = new FileInfo(fileName);
             *  var dirInfo = file.Directory;
             *  if (dirInfo != null && !dirInfo.Exists)
             *          dirInfo.Create();
             *
             *  var parser = new FileIniDataParser();
             *  var data = new IniData();
             *  if(!merge)
             *  {
             *          if (File.Exists(fileName))
             *                  File.Delete(fileName);
             *  }else
             *          data = parser.LoadFile(fileName);
             *  foreach (var section in dict)
             *  {
             *          var sectionName = section.Key;
             *          if (!data.Sections.ContainsSection(sectionName))
             *                  data.Sections.AddSection(sectionName);
             *          var sectionData = section.Value;
             *          var sec = data.Sections[sectionName];
             *
             *          foreach (var keyVal in sectionData)
             *          {
             *                  if (!sec.ContainsKey(keyVal.Key))
             *                          sec.AddKey(keyVal.Key);
             *                  sec[keyVal.Key] = keyVal.Value.ToString();
             *          }
             *
             *  }
             *  parser.SaveFile(fileName, data);*/
        }
Ejemplo n.º 25
0
        public I18n(string sAddinName = "Synergy18", int version = 18)
        {
            m_appdata = System.Environment.GetEnvironmentVariable("LOCALAPPDATA") + "\\Mindjet\\MindManager\\" + version.ToString();
#if PLATFORM_X64
            m_sDLLName = (sAddinName.ToLower().Replace(".connect", "") + "_x64.dll");
#else
            m_sDLLName = (sAddinName.ToLower().Replace(".connect", "") + ".dll");
#endif
            m_hashtable = new System.Collections.Hashtable();

            // Now try to load customization file, I18n.ini
            // located in the same folder as our .dll
            string clsid = "";

            if (version == 18)
            {
                clsid = "CLSID\\{38155112-4ED9-46D8-8A2D-BCB2ECB9A12F}\\InprocServer32";
            }

            if (version == 17)
            {
                clsid = "CLSID\\{7AEA005F-FA38-4421-8F5C-4110A4055AE9}\\InprocServer32";
            }

            RegistryKey rk = Registry.ClassesRoot.OpenSubKey(clsid, false);
            if (null == rk)
            {
                return;
            }
            if (null == rk.GetValue("CodeBase"))
            {
                rk.Close();
                return;
            }
            sPath = rk.GetValue("CodeBase").ToString().ToLower().Replace(m_sDLLName, "").Replace("file:///", "").Replace("/", "\\").Replace("\\x64", "");
            string I18nPath = sPath + "I18n.ini";
            rk.Close();
//			System.Windows.Forms.MessageBox.Show(I18nPath);
            if (File.Exists(sPath + "I18n.default.ini"))
            {
                FileIniDataParser _parser      = new FileIniDataParser();
                IniData           _parsedData  = _parser.LoadFile(sPath + "I18n.default.ini");
                KeyDataCollection _sectionData = _parsedData["l18n.default"];
                if (_sectionData != null)
                {
                    foreach (KeyData _keyData in _sectionData)
                    {
                        m_hashtable[_keyData.KeyName] = _keyData.Value;
                    }
                }
            }

            if (File.Exists(I18nPath))
            {
                FileIniDataParser _parser      = new FileIniDataParser();
                IniData           _parsedData  = _parser.LoadFile(I18nPath);
                KeyDataCollection _sectionData = _parsedData["l18n"];
                if (_sectionData != null)
                {
                    foreach (KeyData _keyData in _sectionData)
                    {
                        m_hashtable[_keyData.KeyName] = _keyData.Value;
                    }
                }
            }
        }
Ejemplo n.º 26
0
        public static PackRes_Def.PackSetting ParsePackSetting(string configFilePath)
        {
            FileIniDataParser iniParser = new FileIniDataParser();
            IniData           data      = iniParser.LoadFile(configFilePath);

            PackRes_Def.PackSetting packSetting = new PackRes_Def.PackSetting();

            SectionData sectionData = data.Sections.GetSectionData("global_settings");


            packSetting.cfg_path = GetValFromCfg(sectionData, "cfg_path");
            packSetting.cfg_path = PackRes_Def.GetPlatformPathString(packSetting.cfg_path);

            packSetting.cfg_file = GetValFromCfg(sectionData, "cfg_file");
            packSetting.cfg_file = PackRes_Def.GetPlatformPathString(packSetting.cfg_file);

            packSetting.res_path = GetValFromCfg(sectionData, "res_path");
            packSetting.res_path = PackRes_Def.GetPlatformPathString(packSetting.res_path);

            packSetting.option   = GetValFromCfg(sectionData, "option");
            packSetting.exp_path = Path.GetFullPath(GetValFromCfg(sectionData, "exp_path"));
            packSetting.exp_path = PackRes_Def.GetPlatformPathString(packSetting.exp_path);

            packSetting.bundle_path  = GetValFromCfg(sectionData, "bundle_path");
            packSetting.bundle_path  = PackRes_Def.GetPlatformPathString(packSetting.bundle_path);
            packSetting.res_idx_path = GetValFromCfg(sectionData, "res_idx_path");
            packSetting.res_idx_path = PackRes_Def.GetPlatformPathString(packSetting.res_idx_path);

            packSetting.index_file = GetValFromCfg(sectionData, "index_file");

            packSetting.policy = GetValFromCfg(sectionData, "policy");

            string compress_str = GetValFromCfg(sectionData, "compress");

            if (compress_str == "false")
            {
                packSetting.compress = false;
            }
            else if (compress_str == "true")
            {
                packSetting.compress = true;
            }
            else
            {
                Debug.LogError("invalid compress setting");
            }

            //parse the file type list
            packSetting.fileTypeList = new List <string>();
            string type_str = GetValFromCfg(sectionData, "res_type_list");

            string[] type_arry = type_str.Split('|');
            foreach (string ty in type_arry)
            {
                if (ty != null && ty != "")
                {
                    packSetting.fileTypeList.Add(ty);
                }
            }
            return(packSetting);
        }