예제 #1
0
        public bool AddRow(string original)
        {
            if (IsTextString(original))
            {
                _rows.Add(CfgTextRow.Create(original));
                return(true);
            }
            int pos = original.IndexOf('=');

            if (pos < 0)
            {
                _rows.Add(CfgTextRow.Create(original));
                return(true);
            }
            string key   = original.Substring(0, pos).Trim();
            string value = original.Substring(pos + 1).Trim();
            var    row   = CfgDataRow.Create(key, value);

            if (row == null)
            {
                _rows.Add(CfgTextRow.Create(original));
                return(true);
            }
            if (ContainsKey(key))
            {
                return(false);
            }
            _rows.Add(row);
            return(true);
        }
예제 #2
0
        public CfgDataRow?AddOrUpdateRow(string key, string value)
        {
            var row = GetRowByKey(key);

            if (row != null)
            {
                row.UpdateValue(value);
                return(row);
            }
            var addRow = CfgDataRow.Create(key, value);

            if (addRow != null)
            {
                _rows.Add(addRow);
                return(addRow);
            }
            return(null);
        }