示例#1
0
        public static Node <string> ParseNodes(this NodeFormatter formatter, string str)
        {
            if (str == null)
            {
                throw new ArgumentNullException(nameof(str));
            }

            using (var reader = new StreamReader(new MemoryStream(Encoding.UTF8.GetBytes(str))))
            {
                return(formatter.ParseNodes(reader));
            }
        }
示例#2
0
        public static string BuildNodes(this NodeFormatter formatter, Node <string> node)
        {
            if (node == null)
            {
                throw new ArgumentNullException(nameof(node));
            }

            using (var stream = new MemoryStream())
            {
                var writer = new StreamWriter(stream);
                formatter.BuildNodes(node, writer);
                writer.Flush();

                stream.Seek(0, SeekOrigin.Begin);
                var reader = new StreamReader(stream);
                return(reader.ReadToEnd());
            }
        }