コード例 #1
0
        public void LoadFromFile()
        {
            Clear();
            var headerRegex = new Regex(HeaderPattern);
            var _buffer = new FullFileBuffer(_filename);

            var header = "";
            foreach (var line in _buffer)
            {
                if (headerRegex.HasNamedCapture(line, "header"))
                    header = headerRegex.GetNamedCapture(line, "header");
                else
                {
                    var keyvalue = line.Split(_delim, 2);

                    if (header == null) continue;
                    if (keyvalue.Length != 2) continue; // Poorly formed line

                    if (_trimWhitespace) keyvalue = keyvalue.Trim();
                    this[header, keyvalue[0]] = keyvalue[1];
                }
            }
        }