Exemple #1
0
        /// <summary>
        /// Parses the specified response.
        /// </summary>
        /// <param name="response">The response.</param>
        private void Parse(string response)
        {
            INI.INIFile file    = new INI.INIFile(response);
            INI.Section section = file.FindSection("RESPONSE");

            foreach (var key in section.Keys)
            {
                try
                {
                    switch (key.Name.ToLower())
                    {
                    case "code":
                        this.Code = key.Value;
                        break;

                    case "description":
                        this.Description = key.Value;
                        break;

                    default:
                        this.result.Add(key.Name, key.Value);
                        break;
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Returns the <see cref="Key.Value">value</see> of a <see cref="key">Key</see>.
        /// </summary>
        /// <param name="SectionName">The <see cref="Section">Section</see> the <see cref="key">Key</see> should be searched under.</param>
        /// <param name="KeyName">The <see cref="key">Key</see> to return the <see cref="Key.Value">value</see> for.</param>
        /// <param name="FileName">The file to return the <see cref="key">Key</see>'s <see cref="Key.Value">value</see> from.</param>
        /// <returns>The <see cref="key">Key</see>'s <see cref="Key.Value">value</see>.</returns>
        /// <remarks>If multiple matching <see cref="Section">Section</see>s exist, only the first occurance is searched. If multiple matching <see cref="key">Key</see>s exist, only the first occurance is returned.</remarks>
        /// <exception cref="SectionNotFoundException">Thrown if the specified <see cref="Section">Section</see> was not found.</exception>
        /// <exception cref="KeyNotFoundException">Thrown is the specified <see cref="key">Key</see> was not found in the first matching <see cref="Section">Section</see>.</exception>
        public static string GetValue(string SectionName, string KeyName, string FileName)
        {
            INIFile INI = new INIFile(FileName);

            return(INI.GetValue(SectionName, KeyName));
        }