AutoQuery.Systems.Ini.GetValue C# (CSharp) Метод

GetValue() публичный Метод

Retrieves the value of an entry inside a section.
/// is null or empty. /// Either section or entry is null.
public GetValue ( string section, string entry ) : object
section string /// The name of the section that holds the entry with the value.
entry string /// The name of the entry where the value is stored.
Результат object
            public override object GetValue(string section, string entry)
            {
                VerifyName();
                VerifyAndAdjustSection(ref section);
                VerifyAndAdjustEntry(ref entry);

                // Loop until the buffer has grown enough to fit the value
                for (int maxSize = 250; true; maxSize *= 2)
                {
                    StringBuilder result = new StringBuilder(maxSize);
                    int size = GetPrivateProfileString(section, entry, "", result, maxSize, Name);

                    if (size < maxSize - 1)
                    {
                        if (size == 0 && !HasEntry(section, entry))
                            return null;
                        return result.ToString();
                    }
                }
            }

Usage Example

Пример #1
0
        static void Main(string[] args)
        {
            #region Load Settings
            _dir = Environment.CurrentDirectory;
            LogConsole._Load();

            try
            {
                if (File.Exists(_dir + _file_config))
                {
                    ini = new Systems.Ini(_dir + _file_config);

                    s_timer = ini.GetValue("Timer", "minutes", 10);
                    max_count = ini.GetValue("Timer", "max", 100);
                    delay = ini.GetValue("Timer", "delay", 10000);
                    infi = ini.GetValue("Timer", "infi", false);

                    _db_user = ini.GetValue("MYSQL", "user", "root");
                    _db_pass = ini.GetValue("MYSQL", "pass", "123456");
                    _db_ipsv = ini.GetValue("MYSQL", "ipsv", "127.0.0.1");
                    _db_name = ini.GetValue("MYSQL", "data", "rakion");
                    _db_port = ini.GetValue("MYSQL", "port", 3306);

                    debug = ini.GetValue("CONSOLE", "debug", false);
                    ini = null;
                    LogConsole.Show("Has loaded your settings successfully");
                }
                else
                {
                    LogConsole.Show("Settings.ini could not be found, using default setting");
                }
            }
            catch (Exception)
            {
                return;
            }
            #endregion

            _SQL.Init(_db_ipsv, _db_user, _db_pass, _db_name, _db_port);
            TimerX _t = new TimerX(s_timer, max_count, infi, delay);
        }