Esempio n. 1
0
File: Toml.cs Progetto: zanedp/Nett
        public static TomlTable ReadStream(Stream stream, TomlSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            return(StreamTomlSerializer.Deserialize(stream, settings));
        }
Esempio n. 2
0
File: Toml.cs Progetto: zanedp/Nett
        /// <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));
            }
        }
Esempio n. 3
0
File: Toml.cs Progetto: zanedp/Nett
        public static T ReadStream <T>(Stream stream, TomlSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            var tt = StreamTomlSerializer.Deserialize(stream, settings);

            return(tt.Get <T>());
        }
Esempio n. 4
0
File: Toml.cs Progetto: zanedp/Nett
        public static TomlTable ReadString(string toRead, TomlSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(toRead)))
            {
                return(StreamTomlSerializer.Deserialize(ms, settings));
            }
        }