示例#1
0
文件: Toml.cs 项目: zanedp/Nett
        public static TomlTable ReadStream(Stream stream, TomlSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            return(StreamTomlSerializer.Deserialize(stream, settings));
        }
示例#2
0
文件: Toml.cs 项目: 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));
            }
        }
示例#3
0
文件: Toml.cs 项目: 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>());
        }
示例#4
0
文件: Toml.cs 项目: 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));
            }
        }