Beispiel #1
0
        /// <summary>
        /// Gets a value indicating whether the markup exension can be inlined.
        /// </summary>
        /// <param name="markup">
        /// The markup extension.
        /// </param>
        /// <returns>
        /// A value indicating whether the markup exension can be inlined.
        /// </returns>
        public static bool CanInline([NotNull] this IMarkupExtensionInfo markup)
        {
            if (markup == null)
            {
                throw new ArgumentNullException(nameof(markup));
            }

            return(!markup.HasNestedArguments && markup.Arguments.Count() < 2);
        }
Beispiel #2
0
        /// <summary>
        /// Tries to parse <paramref name="sourceText"/> and returns a value indicating success.
        /// </summary>
        /// <param name="sourceText">
        /// The source text.
        /// </param>
        /// <param name="result">
        /// The result.
        /// </param>
        /// <returns>
        /// A value indicating whether the source was successfully parsed.
        /// </returns>
        public bool TryParse(string sourceText, out IMarkupExtensionInfo result)
        {
            result = null;

            if (string.IsNullOrWhiteSpace(sourceText))
            {
                return(false);
            }

            var parser = new Parser(MarkupExtensionParser.Language);
            var tree   = parser.Parse(sourceText);

            if (tree.Status != ParseTreeStatus.Parsed)
            {
                return(false);
            }

            result = MarkupExtensionParser.Detokenize(tree);
            return(true);
        }