public EditorConfigFile(string file, Encoding?encoding = null, Version?developmentVersion = null) { if (string.IsNullOrWhiteSpace(file)) { throw new ArgumentException("The given path must be non-empty", nameof(file)); } if (!File.Exists(file)) { throw new ArgumentException($"The given file {file} does not exist", nameof(file)); } FullPath = file; _encoding = encoding ?? Encoding.Default; Directory = Path.GetDirectoryName(file); _lines.AddRange(File.ReadAllLines(FullPath, _encoding)); Global = IniSectionData.Global(); ParseVersion = developmentVersion ?? EditorConfigParser.Version; Parse(); FileConfiguration = new FileConfiguration(ParseVersion, file, Global.Properties.ToDictionary(p => p.Prop.Key, p => p.Prop.Value)); }
private void ResetTo(IEnumerable <string> lines) { _lines.Clear(); _sections.Clear(); _lines.AddRange(lines); Global = IniSectionData.Global(); Parse(); }