Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new T4 code block.
        /// </summary>
        /// <param name="text">The C# code.</param>
        /// <param name="anchor">Where to insert the code.</param>
        /// <returns>A new instance of <see cref="IT4CodeBlock"/>.</returns>
        protected override IT4CodeBlock CreateInlineCodeBlock(string text, ITreeNode anchor)
        {
            ITreeNode existingFeatureNode = anchor.FindPrevNode(node => node is T4FeatureBlock ? TreeNodeActionType.ACCEPT : TreeNodeActionType.CONTINUE);

            return(existingFeatureNode != null
                                ? (IT4CodeBlock)T4ElementFactory.Instance.CreateFeatureBlock(text)
                                : T4ElementFactory.Instance.CreateStatementBlock(text));
        }
 private ITreeNode FindPreviousNonWhiteSpaceNode([NotNull] ITreeNode currentNode)
 {
     return(currentNode.FindPrevNode(x => x is IWhitespaceNode ? TreeNodeActionType.CONTINUE : TreeNodeActionType.ACCEPT));
 }