示例#1
0
        /// <summary>
        /// Deserializes an object from the specified stream (expecting a YAML string).
        /// </summary>
        /// <param name="stream">A YAML string from a stream .</param>
        /// <returns>An instance of the YAML data.</returns>
        public static IEnumerable <T> DeserializeMultiple <T>(Stream stream)
        {
            var serializer = GetYamlSerializer(false);

            var input  = new StreamReader(stream);
            var reader = new EventReader(new Parser(input));

            reader.Expect <StreamStart>();

            while (reader.Accept <DocumentStart>())
            {
                // Deserialize the document
                var doc = serializer.Deserialize <T>(reader);

                yield return(doc);
            }
        }