Beispiel #1
0
        public static Document Load(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                return(new Document());
            }

            using (var asciiReader = new DocumentReader(path))
            {
                var parser = new Parser();
                return(parser.Process(asciiReader));
            }
        }
Beispiel #2
0
        public static Document Parse(string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                return(new Document());
            }

            using (var reader = new StringReader(text))
            {
                using (var asciiReader = new DocumentReader(reader))
                {
                    var parser = new Parser();
                    return(parser.Process(asciiReader));
                }
            }
        }
Beispiel #3
0
        public static Document Load(Stream stream)
        {
            if (stream == null || stream.Length == 0)
            {
                return(new Document());
            }

            using (var reader = new StreamReader(stream))
            {
                using (var asciiReader = new DocumentReader(reader))
                {
                    var parser = new Parser();
                    return(parser.Process(asciiReader));
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Loads a document from the specified path
        /// </summary>
        /// <param name="path">The path.</param>
        /// <returns>
        /// A new instance of <see cref="Document" />
        /// </returns>
        /// <exception cref="System.ArgumentNullException"></exception>
        /// <exception cref="System.AggregateException"></exception>
        public static Document Load(string path)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }

            if (path.Length == 0)
            {
                throw new AggregateException($"{nameof(path)} must not be empty.");
            }

            using (var reader = new DocumentReader(path))
            {
                var parser = new Parser();
                return(parser.Parse(reader));
            }
        }
Beispiel #5
0
        /// <summary>
        /// Parses a document from the specified string
        /// </summary>
        /// <param name="text">The string.</param>
        /// <returns>A new instance of <see cref="Document"/></returns>
        public static Document Parse(string text)
        {
            if (text == null)
            {
                throw new ArgumentNullException(nameof(text));
            }

            if (text.Length == 0)
            {
                throw new ArgumentException($"{nameof(text)} must not be empty.");
            }

            using (var reader = new StringReader(text))
            {
                using (var asciiReader = new DocumentReader(reader))
                {
                    var parser = new Parser();
                    return(parser.Parse(asciiReader));
                }
            }
        }
Beispiel #6
0
        /// <summary>
        /// Loads a document from the specified stream
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <returns>
        /// A new instance of <see cref="Document" />
        /// </returns>
        /// <exception cref="System.ArgumentNullException"></exception>
        /// <exception cref="System.ArgumentException"></exception>
        public static Document Load(Stream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            if (stream.Length == 0)
            {
                throw new ArgumentException($"{nameof(stream)} must not be empty.");
            }

            using (var reader = new StreamReader(stream))
            {
                using (var asciiReader = new DocumentReader(reader))
                {
                    var parser = new Parser();
                    return(parser.Parse(asciiReader));
                }
            }
        }