public IniFileSettings(string fileName) { try { var context = new ParseContext(); _fileInfo = ReadedFileInfo.Create(fileName, stream => { using (var sr = new StreamReader(stream, Encoding.UTF8)) context.ParseSource(sr.ReadToEnd()); }); _sections = new List<Section>(context.Sections); } catch(SystemException ex) { throw new ApplicationException(string.Format("Unable to load file `{0}'", fileName), ex); } }
public IniFileSettings(string fileName, IStringConverter converter, IGenericDeserializer deserializer) : base(converter, deserializer) { try { fileName = System.IO.Path.GetFullPath(fileName); var content = File.ReadAllBytes(fileName); var context = new ParseContext(); context.ParseSource(Encoding.UTF8.GetString(content)); _sections = new List<Section>(context.Sections); Identity = this.GetIdentitySource(fileName); Path = System.IO.Path.GetDirectoryName(fileName); _fm = this.GetMonitoring(fileName, content); } catch(SystemException ex) { throw new ApplicationException(string.Format("Unable to load file `{0}'", fileName), ex); } }
public static List<Section> Parse(string text) { var context = new ParseContext(); context.ParseSource(text); return new List<Section>(context.Sections); }