示例#1
0
    public void LoadSettings()
    {
        try
        {
            _xm.Login();
            string raw = _xm.GetConfigFile(AdminPanelConstants.serverTab);
            _xm.Logout();
            string line = string.Empty;

            using (StringReader sr = new StringReader(raw))
            {
                while ((line = sr.ReadLine()) != null)
                {
                    line = line.Trim();
                    if (line == ".")
                    {
                        break;
                    }
                    XMSettingsRow row = XMSettingsRow.Parse(line);
                    if (row != null)
                    {
                        _rows.Add(row);
                    }
                }
            }
        }
        catch (Exception error)
        {
            Log.WriteException(error);
        }
    }
示例#2
0
    public void SetXMSettingsRow(XMSettingsRow row)
    {
        int index = _rows.IndexOf(row);

        if (index >= 0)
        {
            _rows[index].IsComment = row.IsComment;
            _rows[index].Key       = row.Key;
            _rows[index].Value     = row.Value;
        }
        else
        {
            _rows.Add(row);
        }
    }
示例#3
0
    public XMSettingsRow GetXMSettingsRow(string key)
    {
        XMSettingsRow result = null;
        int           index  = 0;
        XMSettingsRow item   = new XMSettingsRow();

        item.Key = key;
        while ((index >= 0) && (index < _rows.Count))
        {
            index = _rows.IndexOf(item, index);
            if (index <= 0)
            {
                continue;
            }
            result = _rows[index];
            if (!result.IsComment)
            {
                break;
            }
            index++;
        }
        return(result);
    }