Ejemplo n.º 1
0
        public bool TryParse(string sourceText, out MarkupExtension graph)
        {
            graph = null;

            try
            {
                ParseTree tree = this.parser.Parse(sourceText);
#if DEBUG
                // Save result tree for debugging purposes.
                this.LastParseTree = tree;
                this.LastException = null;
#endif
                if (tree.Status == ParseTreeStatus.Parsed)
                {
                    graph = MarkupExtension.Create(tree.Root);
                    return(true);
                }
            }
#if DEBUG
            catch (Exception ex)
            {
                this.LastParseTree = null;
                this.LastException = ex;
            }
#else
            catch
            {
                // ignored
            }
#endif
            return(false);
        }
Ejemplo n.º 2
0
        private static IEnumerable <Argument> GetArguments(IEnumerable <ParseTreeNode> nodes)
        {
            foreach (var node in nodes)
            {
                var argument = PositionalArgument.Create(node) ?? (Argument)NamedArgument.Create(node);

                if (argument != null)
                {
                    yield return(argument);
                }
                else
                {
                    // Unwrap argument.
                    foreach (var markupExtensionArgument in MarkupExtension.GetArguments(node.ChildNodes))
                    {
                        yield return(markupExtensionArgument);
                    }
                }
            }
        }
Ejemplo n.º 3
0
 public static Value Create(ParseTreeNode node)
 {
     return(LiteralValue.Create(node) ?? (Value)MarkupExtension.Create(node));
 }