/// <summary> /// Reads the TOML contents from some file and converts it to a CLR object. /// </summary> /// <typeparam name="T">The type of the CLR object.</typeparam> /// <param name="filePath">The absolute or relative path to the file.</param> /// <param name="settings">The settings used to process the TOML content.</param> /// <returns>A CLR object representing the TOML contents of the file.</returns> /// <exception cref="ArgumentNullException">If *filePath* is **null**.</exception> /// <exception cref="ArgumentNullException">If *settings* is **null**</exception> public static T ReadFile <T>(string filePath, TomlSettings settings) { filePath.CheckNotNull(nameof(filePath)); settings.CheckNotNull(nameof(settings)); var tt = ReadFile(filePath, settings); return(tt.Get <T>()); }
/// <summary> /// Reads the TOML contents from some file and maps it into a TomlTable structure. /// </summary> /// <param name="filePath">The absolute or relative path to the file.</param> /// <param name="settings">The settings used to process the TOML content.</param> /// <returns>A <see cref="TomlTable"/>corresponding to the file content.</returns> public static TomlTable ReadFile(string filePath, TomlSettings settings) { filePath.CheckNotNull(nameof(filePath)); settings.CheckNotNull(nameof(settings)); using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read)) { return(StreamTomlSerializer.Deserialize(fs, settings)); } }