/// <summary>Creates a new feature block with new type members.</summary> /// <param name="originalFile">The original T4 file where the feature block must be created.</param> /// <param name="text">The code representing new C# type members.</param> /// <param name="first">The first node.</param> /// <param name="last">The last node.</param> /// <returns>A <see cref="TreeTextRange"/> representing the code range in the newly created feature block.</returns> protected override TreeTextRange CreateTypeMemberNode(IFile originalFile, string text, ITreeNode first, ITreeNode last) { var featureBlock = T4ElementFactory.CreateFeatureBlock(text); featureBlock = ((IT4File)originalFile).AddFeatureBlock(featureBlock); return(featureBlock.Code.GetTreeTextRange()); }
/// <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) { var existingFeatureNode = anchor.FindPreviousNode(node => node is IT4FeatureBlock ? TreeNodeActionType.ACCEPT : TreeNodeActionType.CONTINUE); return(existingFeatureNode != null ? T4ElementFactory.CreateFeatureBlock(text) : T4ElementFactory.CreateStatementBlock(text)); }