示例#1
0
        private static string ElaboratedParsing(IniData parsedData, StreamIniDataParser parser)
        {
            StringBuilder sb = new StringBuilder();

            //Process data: print contents of the file into screen
            foreach (SectionData sectionData in parsedData.Sections)
            {
                //Print comments for current section
                foreach (string sectionComment in sectionData.Comments)
                    sb.AppendLine(parser.CommentDelimiter + sectionComment);

                //Print section's name
                sb.AppendLine(
                    parser.SectionDelimiters[0] + sectionData.SectionName + parser.SectionDelimiters[1]);

                sb.AppendLine();

                //Print section's key-value pairs with it's comments
                foreach (KeyData keyData in sectionData.Keys)
                {
                    //Print comments for current key
                    foreach (string keyComment in keyData.Comments)
                        sb.AppendLine(parser.CommentDelimiter + keyComment);

                    //Print key and value
                    sb.AppendLine(keyData.KeyName + " " + parser.KeyValueDelimiter + " " + keyData.Value);

                    sb.AppendLine();
                }

                sb.AppendLine();
            }

            return sb.ToString();
        }
示例#2
0
 /// <summary>
 ///     Force load data from ini file
 /// </summary>
 /// <param name="pathToIni">Path to ini file</param>
 public void ForceLoadData(string pathToIni)
 {
     if (data != null)
     {
         data = manager.forceLoadIniData(pathToIni);
     }
 }
示例#3
0
 public IniLoader(string iniFilePath)
 {
     if (iniFilePath != null && File.Exists(iniFilePath))
     {
         data = manager.getIniData(iniFilePath);
     }
 }
示例#4
0
        /// <summary>
        ///     EN: Force loading data from specyfic file without read from cache, but set to temporary cache and add to cache
        ///     container
        /// </summary>
        /// <param name="pathToIni">Path to ini file</param>
        /// <returns>Data from ini file</returns>
        public IniData forceLoadIniData(string pathToIni)
        {
            if (pathToIni != null && File.Exists(pathToIni))
            {
                lock (syncValue)
                {
                    nameCache = pathToIni;
                    cache = parser.LoadFile(pathToIni);
                }

                lock (syncContainer)
                {
                    if (container.Count > 0 && container.ContainsKey(nameCache))
                    {
                        updateContainerValue(nameCache, cache);
                    }
                    else
                    {
                        container.Add(nameCache, cache);
                    }
                }

                return cache;
            }

            return null;
        }
示例#5
0
文件: Ini.cs 项目: andrusender/YesPos
 private Config(string path)
 {
     FilePath = path;
     FileHandler = new FileIniDataParser();
     ConfigHandler = FileHandler.LoadFile(path);
     //Fill Dictionary
     ReplacingData.Add("$(root)",Global.AppDir);
 }
示例#6
0
 public Tour(IniData config, String configFilePath)
 {
     InitializeComponent();
     this.config = config;
     this.configFilePath = configFilePath;
     tourScreen = new ArrayList();
     initializeTourScreenArray();
     currentScreen = 0;
     showCurrentScreen();
     setButtonStates();
     setLabels();
 }
示例#7
0
        private static IniData ModifyINIData(IniData modifiedParsedData)
        {
            modifiedParsedData["GeneralConfiguration"]["setMaxErrors"] = "10";
            modifiedParsedData.Sections.AddSection("newSection");
            modifiedParsedData.Sections.GetSectionData("newSection").Comments
                .Add("This is a new comment for the section");
            modifiedParsedData.Sections.GetSectionData("newSection").Keys.AddKey("myNewKey", "value");
            modifiedParsedData.Sections.GetSectionData("newSection").Keys.GetKeyData("myNewKey").Comments
            .Add("new key comment");

            return modifiedParsedData;
        }
        public void WritingTotring_Test()
        {
            IniData data = new IniData();

            data.Sections.AddSection("newSection1");
            data.Sections["newSection1"].AddKey("newKey1", "newValue1");
            data.Sections["newSection1"].AddKey("newKey2", "newValue5");

            string result = sip.WriteString(data);

            Assert.That(result, Is.Not.Empty);
            Assert.That(result.Length, Is.Not.EqualTo(0));
        }
示例#9
0
        /// <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();
            }
        }
示例#10
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;
 }
示例#11
0
 public Form1()
 {
     InitializeComponent();
     //if (!AllocConsole())
        // MessageBox.Show("Failed");
     //set up ini file parcer
     parcer = new FileIniDataParser();
     iniFile = parcer.LoadFile("config.ini");
     //set default backup location
     bkuploc = iniFile["appdata"]["defaultBackuploc"];
     output = "Click backup to begin.....";
     outputlabel.Text = output;
     dbclient = new DropNetClient("ogpmt0vuae0mkr4", "8s77mh9omajr7x9");
     newUser = false;
 }
        private IniData ConvertRuleToIniData(Rule rule)
        {
            var data = new IniData();

            data.Sections = new SectionDataCollection();
            data.Sections.AddSection("rule");
            var section = data.Sections["rule"];
            section.AddKey("name", rule.Name);
            section.AddKey("content", rule.Content);
            section.AddKey("language", rule.RuleLanguage.ToString());
            section.AddKey("schedule", rule.Schedule.ToString("dd/MM/yyyy hh:mm"));
            section.AddKey("action", rule.Action.ToString());
            section.AddKey("action-value", rule.ActionValue);

            return data;
        }
示例#13
0
        /// <summary>
        /// Creates a string from the INI data.
        /// </summary>
        /// <param name="iniData">An <see cref="IniData"/> instance.</param>
        /// <returns>
        /// A formatted string with the contents of the
        /// <see cref="IniData"/> instance object.
        /// </returns>
        public string WriteString(IniData iniData)
        {
            using (MemoryStream ms = new MemoryStream())
            {
                using (StreamWriter sw = new StreamWriter(ms))
                {
                    WriteData(sw, iniData);
                    sw.Flush();

                    string result = System.Text.Encoding.UTF8.GetString(ms.ToArray());

                    ms.Close();
                    sw.Close();

                    return result;
                }
            }
        }
示例#14
0
 public ConfigurationGeneral LoadGeneral(string path)
 {
     IniData data = new IniData();
     try
     {
         data = Load(path);
     }
     catch (FileNotFoundException)
     {
         Log.LogMessage(string.Format("Configuration does not exist. Creating new configuration in {0}...", path));
         data.Sections.AddSection("General");
         data["General"].AddKey("Portable");
         data["General"]["Portable"] = "1";
         parser.SaveFile(path, data);
         Log.LogMessage(string.Format("Configuration created.", path));
     }
     ConfigurationGeneral configuration = new ConfigurationGeneral();
     configuration.Portable = data["General"]["Portable"];
     return configuration;
 }
        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);
        }
        /// <summary>
        /// Implements saving a file from disk.
        /// </summary>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="parsedData">IniData to be saved as an INI file.</param>
        public void SaveFile(string fileName, IniData parsedData)
        {
            if (string.IsNullOrEmpty(fileName))
                throw new ArgumentException("Bad filename.");

            if (parsedData == null)
                throw new ArgumentNullException("parsedData");

            try
            {
                using (FileStream fs = File.Open(fileName, FileMode.Create, FileAccess.Write))
                {
                    using (StreamWriter sr = new StreamWriter(fs))
                    {
                        WriteData(sr, parsedData);
                    }
                }

            }
            catch (IOException ex)
            {
                throw new ParsingException(String.Format("Could not save data to file {0}", fileName), ex);
            }
        }
示例#17
0
 public void SaveFile(StorageFile file, IniData parsedData)
 {
     WriteFile(file, parsedData, Encoding.ASCII);
 }
示例#18
0
        /// <summary>
        ///     EN: Set data and set data to cache
        /// </summary>
        /// <returns>Data from ini file</returns>
        private void setDataSetCache(string pathToIni)
        {
            if (pathToIni != null && File.Exists(pathToIni))
            {
                lock (syncValue)
                {
                    nameCache = pathToIni;
                    cache = parser.LoadFile(pathToIni);
                }

                lock (syncContainer)
                {
                    container.Add(nameCache, cache);
                }
            }
        }
示例#19
0
        public void LoadProfile(string path)
        {
            IniData data = new IniData();
            if (!Path.HasExtension(path))
            {
                var storedprofile = Path.Combine(Globals.DefaultProfileDirectory, string.Concat(path, ".ini"));
                if (File.Exists(storedprofile))
                {
                    path = storedprofile;
                }
                else
                {
                    throw new FileNotFoundException("Relative profile not found.", storedprofile);
                }
            }
            else if (path.Equals(Globals.DefaultProfileFile) && !File.Exists(path))
            {
                // create if not exist
                if (!Directory.Exists(Path.GetDirectoryName(path)))
                {
                    Log.LogMessage(string.Format("Profile directory not found. Creating profile directory..."));
                    Directory.CreateDirectory(Path.GetDirectoryName(path));
                    Log.LogMessage(string.Format("Profile directory created at {0}", Path.GetDirectoryName(path)));
                }
                Log.LogMessage(string.Format("Default profile does not exist. Creating new default profile in {0}...", path));
                data.Sections.AddSection("Profile");
                data["Profile"].AddKey("Hostname");
                data["Profile"].AddKey("Username");
                data["Profile"].AddKey("Password");
                data["Profile"].AddKey("Encryption");
                data["Profile"].AddKey("EncryptionImplicit");
                data["Profile"].AddKey("ForceEncryption");
                data["Profile"].AddKey("RemoteDir");
                data["Profile"].AddKey("Mode");
                data["Profile"].AddKey("ClipboardURL");
                data["Profile"].AddKey("ClipboardEnabled");
                data["Profile"].AddKey("SshHostKey");
                data["Profile"].AddKey("Soundfile");
                data["Profile"].AddKey("SoundEnabled");
                parser.SaveFile(path, data);
                Log.LogMessage("Default profile created.");
                Console.WriteLine("Default profile created. You'll probably want to edit credentials. Program will now exit.");
                Environment.Exit(0);
            }
            else if (!File.Exists(path))
            {
                throw new FileNotFoundException("Profile not found.", Path.GetFullPath(path));
            }

            try
            {
                data = Load(path);
            }
            catch (ParsingException)
            {
                throw;
            }
            ConfigurationProfile profile = new ConfigurationProfile();
            try
            {
                Encryption = data["Profile"]["Encryption"];
                EncryptionImplicit = data["Profile"]["EncryptionImplicit"];
                ForceEncryption = data["Profile"]["ForceEncryption"];
                Hostname = data["Profile"]["Hostname"];
                Username = data["Profile"]["Username"];
                Password = data["Profile"]["Password"];
                RemoteDir = data["Profile"]["RemoteDir"];
                Mode = data["Profile"]["Mode"];
                ClipboardURL = data["Profile"]["ClipboardURL"];
                ClipboardEnabled = data["Profile"]["ClipboardEnabled"];
                SshHostKey = data["Profile"]["SshHostKey"];
                Soundfile = data["Profile"]["Soundfile"];
                SoundEnabled = data["Profile"]["SoundEnabled"];
            }
            catch (NullReferenceException)
            {
                throw new FileLoadException("Profile is corrupted.");
            }
        }
示例#20
0
 /// <summary>
 /// Creates a string from the INI data.
 /// </summary>
 /// <param name="iniData">An <see cref="IniData" instance.</param>
 /// <returns>
 /// A formatted string with the contents of the
 /// <see cref="IniData" instance object.
 /// </returns>
 public string WriteString(IniData iniData) => iniData.ToString();
示例#21
0
文件: Settings.cs 项目: Jaex/SMBStats
        public void Save()
        {
            try
            {
                IniData data = new IniData();
                data.Sections.AddSection("Settings");
                data.Sections.GetSectionData("Settings").Keys.AddKey("AutoLoad", AutoLoad.ToString());
                data.Sections.GetSectionData("Settings").Keys.AddKey("AutoUpdate", AutoUpdate.ToString());
                data.Sections.GetSectionData("Settings").Keys.AddKey("LastLoadPath", LastLoadPath);
                data.Sections.GetSectionData("Settings").Keys.AddKey("SteamID", SteamID.ToString());
                data.Sections.GetSectionData("Settings").Keys.AddKey("UserKey", UserKey);

                FileIniDataParser parser = new FileIniDataParser();
                parser.SaveFile(SettingPath, data);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());
            }
        }
 private string getInfoData(IniData infoData, string key, string defaultValue = "")
 {
     if (infoData.Global.ContainsKey(key))
         return infoData.Global.GetKeyData(key).Value;
     return defaultValue;
 }
示例#23
0
 public IniParser(string path)
 {
     _parser = new Parser(path);
     _data   = new IniData();
 }
示例#24
0
 /// <summary>
 ///     EN: Update cache value in container on specific index
 /// </summary>
 /// <param name="pathToIni">Path to ini file</param>
 /// <param name="data">Data from ini file</param>
 private void updateContainerValue(string pathToIni, IniData data)
 {
     if (pathToIni != null && data != null)
     {
         container[pathToIni] = data;
     }
 }
 public void SaveFile(string filePath, IniData parsedData)
 {
     this.WriteFile(filePath, parsedData, Encoding.UTF8);
 }
示例#26
0
 protected void Save(string filePath, IniData iniData)
 {
     IniParser.FileIniDataParser parser = new IniParser.FileIniDataParser();
     parser.SaveFile(filePath, iniData);
 }
示例#27
0
 public void SaveFile(string filePath, IniData parsedData)
 {
     WriteFile(filePath, parsedData, Encoding.ASCII);
 }
示例#28
0
        /*
        /// <summary>
        /// EN: Create key with value in section
        /// </summary>
        /// <param name="section">Section name</param>
        /// <param name="key">Key name</param>
        /// <param name="value">Key value</param>
        public void setValue(string section, string key, string value)
        {

            if (section != null)
            {

                SectionData Section = null;

                if (data.Sections.GetSectionData(section) != null)
                {
                    // Get section from data
                    Section = data.Sections.GetSectionData(section);
                }
                else
                {
                    // Creating section
                    data.Sections.AddSection(section);
                    // Get section from data
                    Section = data.Sections.GetSectionData(section);
                }

                if (key != null)
                {

                    KeyData Key = null;

                    if (Section.Keys.GetKeyData(key) != null)
                    {
                        // Get key from Section
                        Key = Section.Keys.GetKeyData(key);
                    }
                    else
                    {
                        // Adding key to Sectrion
                        Section.Keys.AddKey(key);
                        // Get key from Section
                        Key = Section.Keys.GetKeyData(key);
                    }

                    if (value != null)
                    {
                        // Set value to key
                        Key.Value = value;
                    }
                }
            }
        }

        /// <summary>
        /// EN: TODO
        /// </summary>
        /// <param name="section"></param>
        /// <param name="sectionComment"></param>
        /// <param name="key"></param>
        /// <param name="keyComment"></param>
        /// <param name="value"></param>
        public void setValue(string section, string sectionComment, string key, string keyComment, string value)
        {

            if (section != null)
            {

                SectionData Section = null;

                if (data.Sections.GetSectionData(section) != null)
                {
                    // Get section from data
                    Section = data.Sections.GetSectionData(section);
                }
                else
                {
                    // Creating section
                    data.Sections.AddSection(section);
                    // Get section from data
                    Section = data.Sections.GetSectionData(section);
                }

                if (sectionComment != null && !sectionComment.Equals(""))
                {
                    Section.Comments.Add(sectionComment);
                }

                if (key != null)
                {

                    KeyData Key = null;

                    if (Section.Keys.GetKeyData(key) != null)
                    {
                        // Get key from Section
                        Key = Section.Keys.GetKeyData(key);
                    }
                    else
                    {
                        // Adding key to Sectrion
                        Section.Keys.AddKey(key);
                        // Get key from Section
                        Key = Section.Keys.GetKeyData(key);
                    }

                    if (keyComment != null && !keyComment.Equals(""))
                    {
                        Key.Comments.Add(keyComment);
                    }

                    if (value != null)
                    {
                        // Set value to key
                        Key.Value = value;
                    }
                }
            }
        }

        /// <summary>
        /// EN: TODO
        /// </summary>
        /// <param name="section"></param>
        /// <param name="key_value_grupe">Group of keys and values</param>
        public void SetValue(string section, Dictionary<string, string> keyGroup)
        {

            if (section != null)
            {
                SectionData Section = null;

                try
                {
                    // Get section from data
                    Section = data.Sections.GetSectionData(section);
                }
                catch
                {
                    // Creating section
                    data.Sections.AddSection(section);
                    // Get section from data
                    Section = data.Sections.GetSectionData(section);
                }

                if (Section != null && keyGroup != null && keyGroup.Count > 0)
                {

                    KeyData Key = null;

                    foreach (KeyValuePair<string, string> pair in keyGroup)
                    {
                        try
                        {
                            // Get key from Section
                            Key = Section.Keys.GetKeyData(pair.Key);
                        }
                        catch
                        {
                            // Adding key to Sectrion
                            Section.Keys.AddKey(pair.Key);
                            // Get key from Section
                            Key = Section.Keys.GetKeyData(pair.Key);
                        }

                        if (Key != null && pair.Value != null)
                        {
                            // Add value to key
                            Key.Value = pair.Value;
                        }

                    }

                }

            }

        }
        */
        /// <summary>
        ///     EN: Save ini data to file
        /// </summary>
        /// <param name="filePath">file path</param>
        /// <returns>true if file saved, false otherwise</returns>
        /// <example>Example: how to save file</example>
        /// <code>if(SaveFile()) then...</code>
        public bool SaveFile()
        {
            bool result = false;

            if (path != null && data != null)
            {
                try
                {
                    parser.SaveFile(path, data);
                    result = true;
                }
                catch (Exception ex)
                {
                    Logger.Error(ex.Message);
                    result = false;
                }
            }

            if (result)
            {
                data = null;
            }

            return result;
        }
示例#29
0
 /// <summary>
 ///     Saves INI data to a file.
 /// </summary>
 /// <remarks>
 ///     Creats an ASCII encoded file by default.
 /// </remarks>
 /// <param name="fileName">
 ///     Name of the file.
 /// </param>
 /// <param name="parsedData">
 ///     IniData to be saved as an INI file.
 /// </param>
 public void SaveFile(string fileName, IniData parsedData)
 {
     SaveFile(fileName, parsedData, Encoding.ASCII);
 }
示例#30
0
 public IniParser()
 {
     _parser = new Parser();
     _data   = new IniData();
 }
示例#31
0
        public injector(String path)
        {
            this.path = path;

            parsedData = parser.LoadFile(path);
        }
示例#32
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);
         }
     }
 }
示例#33
0
 /// <summary>
 ///	 Saves INI data to a file.
 /// </summary>
 /// <remarks>
 ///	 Creats an ASCII encoded file by default.
 /// </remarks>
 /// <param name="fileName">
 ///	 Name of the file.
 /// </param>
 /// <param name="parsedData">
 ///	 IniData to be saved as an INI file.
 /// </param>
 public void SaveFile(string fileName, IniData parsedData)
 {
     SaveFile(fileName, parsedData, new System.Text.UTF8Encoding());
 }
示例#34
0
 /// <summary>
 /// Creates a string from the INI data.
 /// </summary>
 /// <param name="iniData">An <see cref="IniData"/> instance.</param>
 /// <returns>
 /// A formatted string with the contents of the
 /// <see cref="IniData"/> instance object.
 /// </returns>
 public string WriteString(IniData iniData)
 {
     return(iniData.ToString());
 }
示例#35
0
        private void readConfiguration(String filePath)
        {
            FileIniDataParser parser = new FileIniDataParser();

            int i = 3;

            while (i != 0)
            {
                try
                {
                    config = parser.LoadFile(filePath);

                    EntriesInView = Convert.ToInt32(config["settings"]["entriesInView"]);
                    Boolean autoTrigger = Convert.ToBoolean(config["settings"]["autoTrigger"]);
                    isEnabled = Convert.ToBoolean(config["settings"]["enableDisable"]);
                    TriggerDelay = Convert.ToInt32(config["settings"]["triggerDelay"]);
                    this.tourEnabled = Convert.ToBoolean(config["settings"]["tourEnabled"]);
                    setHotkeys(config);

                    if (autoTrigger)
                    {
                        Mode = TriggerMode.AUTO_TRIGGER;
                    }
                    else
                    {
                        Mode = TriggerMode.MANUAL_TRIGGER;
                    }
                    break;
                }
                catch (ParsingException e)
                {
                    Thread.Sleep(100);
                    i--;
                }
            }
        }
示例#36
0
 /// <summary>
 ///     Saves INI data to a file.
 /// </summary>
 /// <remarks>
 ///     Creats an ASCII encoded file by default.
 /// </remarks>
 /// <param name="fileName">
 ///     Name of the file.
 /// </param>
 /// <param name="parsedData">
 ///     IniData to be saved as an INI file.
 /// </param>
 public void SaveFile(string fileName, IniData parsedData)
 {
     SaveFile(fileName, parsedData, System.Text.ASCIIEncoding);
 }
示例#37
0
        private void setHotkeys(IniData config)
        {
            triggerSuggestionPopUpKeyMod1 = "0";
            triggerSuggestionPopUpKeyMod2 = "0";

            extendWordKeyMod1 = "0";
            extendWordKeyMod2 = "0";
            reduceWordKeyMod1 = "0";
            reduceWordKeyMod2 = "0";
            extendSentenceKeyMod1 = "0";
            extendSentenceKeyMod2 = "0";
            reduceSentenceKeyMod1 = "0";
            reduceSentenceKeyMod2 = "0";
            extendParagraphKeyMod1 = "0";
            extendParagraphKeyMod2 = "0";
            reduceParagraphKeyMod1 = "0";
            reduceParagraphKeyMod2 = "0";

            String str;
            String[] strArr;

            /* Retrieving and Setting Hotkeys for other functions */
            str = config["hotkeys"]["triggerSuggestionPopUp"];
            strArr = str.Split('+');
            for (int i = strArr.Length - 1; i >= 0; i--)
            {
                if (i == strArr.Length - 1)
                    triggerSuggestionPopUpKey = KeyboardMapping.Keys[strArr[i].Trim(' ')];
                else if (i == strArr.Length - 2)
                    triggerSuggestionPopUpKeyMod1 = strArr[i].Trim(' ');
                else
                    triggerSuggestionPopUpKeyMod2 = strArr[i].Trim(' ');
            }

            /* Retrieving and Setting Hotkeys for extend Suggestion */
            str = config["hotkeys"]["extendWord"];
            strArr = str.Split('+');
            for (int i = strArr.Length - 1; i >= 0; i--)
            {
                if (i == strArr.Length - 1)
                    extendWordKey = KeyboardMapping.Keys[strArr[i].Trim(' ')];
                else if (i == strArr.Length - 2)
                    extendWordKeyMod1 = strArr[i].Trim(' ');
                else
                    extendWordKeyMod2 = strArr[i].Trim(' ');
            }

            str = config["hotkeys"]["reduceWord"];
            strArr = str.Split('+');
            for (int i = strArr.Length - 1; i >= 0; i--)
            {
                if (i == strArr.Length - 1)
                    reduceWordKey = KeyboardMapping.Keys[strArr[i].Trim(' ')];
                else if (i == strArr.Length - 2)
                    reduceWordKeyMod1 = strArr[i].Trim(' ');
                else
                    reduceWordKeyMod2 = strArr[i].Trim(' ');
            }

            str = config["hotkeys"]["extendSentence"];
            strArr = str.Split('+');
            for (int i = strArr.Length - 1; i >= 0; i--)
            {
                if (i == strArr.Length - 1)
                    extendSentenceKey = KeyboardMapping.Keys[strArr[i].Trim(' ')];
                else if (i == strArr.Length - 2)
                    extendSentenceKeyMod1 = strArr[i].Trim(' ');
                else
                    extendSentenceKeyMod2 = strArr[i].Trim(' ');
            }

            str = config["hotkeys"]["reduceSentence"];
            strArr = str.Split('+');
            for (int i = strArr.Length - 1; i >= 0; i--)
            {
                if (i == strArr.Length - 1)
                    reduceSentenceKey = KeyboardMapping.Keys[strArr[i].Trim(' ')];
                else if (i == strArr.Length - 2)
                    reduceSentenceKeyMod1 = strArr[i].Trim(' ');
                else
                    reduceSentenceKeyMod2 = strArr[i].Trim(' ');
            }

            str = config["hotkeys"]["extendParagraph"];
            strArr = str.Split('+');
            for (int i = strArr.Length - 1; i >= 0; i--)
            {
                if (i == strArr.Length - 1)
                    extendParagraphKey = KeyboardMapping.Keys[strArr[i].Trim(' ')];
                else if (i == strArr.Length - 2)
                    extendParagraphKeyMod1 = strArr[i].Trim(' ');
                else
                    extendParagraphKeyMod2 = strArr[i].Trim(' ');
            }

            str = config["hotkeys"]["reduceParagraph"];
            strArr = str.Split('+');
            for (int i = strArr.Length - 1; i >= 0; i--)
            {
                if (i == strArr.Length - 1)
                    reduceParagraphKey = KeyboardMapping.Keys[strArr[i].Trim(' ')];
                else if (i == strArr.Length - 2)
                    reduceParagraphKeyMod1 = strArr[i].Trim(' ');
                else
                    reduceParagraphKeyMod2 = strArr[i].Trim(' ');
            }
        }
        /// <summary>
        /// Writes the ini data to a stream.
        /// </summary>
        /// <param name="writer">The writer.</param>
        /// <param name="iniData">An <see cref="IniData"/> instance .</param>
        public void WriteData(StreamWriter writer, IniData iniData)
        {
            SectionDataCollection sdc = iniData.Sections;

            //Write sections
            foreach (SectionData sd in sdc)
            {
                //Write section comments
                foreach (string sectionComment in sd.Comments)
                    writer.WriteLine(string.Format("{0}{1}", CommentDelimiter, sectionComment));

                //Write section name
                writer.WriteLine(string.Format(
                    "{0}{1}{2}",
                    SectionDelimiters[0], sd.SectionName, SectionDelimiters[1]));

                //Write section keys
                foreach (KeyData kd in sd.Keys)
                {
                    //Write key comments
                    foreach (string keyComment in kd.Comments)
                        writer.WriteLine(string.Format("{0}{1}", CommentDelimiter, keyComment));

                    //Write key and value
                    writer.WriteLine(string.Format(
                        "{0} {1} {2}",
                        kd.KeyName, KeyValueDelimiter, kd.Value));
                }

                writer.WriteLine();     //blank line

            }
        }
示例#39
0
 public HashFile(IniData iniData)
 {
     this.iniData = iniData;
 }