public static IniFile Load(string content, IniLoadSettings settings = null) { settings = settings ?? IniLoadSettings.Default; Encoding encoding = settings.Encoding ?? Encoding.UTF8; byte[] contentBytes = encoding.GetBytes(content); var stream = new MemoryStream(contentBytes.Length); stream.Write(contentBytes, 0, contentBytes.Length); stream.Seek(0, SeekOrigin.Begin); return(new IniFile(stream)); }
public IniFile(string iniFilePath, IniLoadSettings settings = null) { if (iniFilePath == null) { throw new ArgumentNullException("iniFilePath"); } if (!File.Exists(iniFilePath)) { throw new ArgumentException(string.Format("INI file '{0}' does not exist", iniFilePath), "iniFilePath"); } settings = settings ?? IniLoadSettings.Default; _comparison = settings.CaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase; using (var reader = new StreamReader(iniFilePath, settings.Encoding ?? Encoding.UTF8, settings.DetectEncoding)) ParseIniFile(reader); }
public IniFile(Stream stream, IniLoadSettings settings = null) { if (stream == null) { throw new ArgumentNullException("stream"); } if (!stream.CanRead) { throw new ArgumentException("Cannot read from specified stream", "stream"); } settings = settings ?? IniLoadSettings.Default; _comparison = settings.CaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase; using (var reader = new StreamReader(stream, settings.Encoding ?? Encoding.UTF8, settings.DetectEncoding)) ParseIniFile(reader); }
public IniFile(IniLoadSettings settings = null) { settings = settings ?? IniLoadSettings.Default; _comparison = settings.CaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase; }