예제 #1
0
        /// <summary>
        /// Parse directory and load a parser for every document
        /// </summary>
        /// <param name="path"></param>
        /// <param name="searchPattern"></param>
        /// <param name="output"></param>
        /// <param name="outputError"></param>
        /// <returns></returns>
        private static IEnumerable <WorkflowConfigParser> ParseDirectory(string path, string searchPattern, TextWriter output = null, TextWriter outputError = null)
        {
            DirectoryInfo dir = new DirectoryInfo(path);

            dir.Refresh();
            foreach (var item in dir.GetFiles(searchPattern))
            {
                yield return(WorkflowConfigParser.ParsePath(item.FullName, output, outputError));
            }
        }
예제 #2
0
        public static WorkflowConfigParser ParseString(StringBuilder source, string sourceFile = "", TextWriter output = null, TextWriter outputError = null)
        {
            ICharStream stream = CharStreams.fromstring(source.ToString());

            var parser = new WorkflowConfigParser(output, outputError)
            {
                File    = sourceFile ?? string.Empty,
                Content = source,
                Crc     = Crc32.Calculate(source),
            };

            parser.ParseCharStream(stream);
            return(parser);
        }
예제 #3
0
        /// <summary>
        /// Load specified document in a dedicated parser
        /// </summary>
        /// <param name="source"></param>
        /// <param name="output"></param>
        /// <param name="outputError"></param>
        /// <returns></returns>
        public static WorkflowConfigParser ParsePath(string source, TextWriter output = null, TextWriter outputError = null)
        {
            var         payload = LoadContent(source);
            ICharStream stream  = CharStreams.fromstring(payload.ToString());

            var parser = new WorkflowConfigParser(output, outputError)
            {
                File    = source,
                Content = payload,
                Crc     = Crc32.Calculate(payload),
            };

            parser.ParseCharStream(stream);

            return(parser);
        }