/// <summary>
            /// Insert the string from the include file inside the include directive tag
            /// </summary>
            /// <remarks></remarks>
            private void ExpandIncludeFiles(ParseTreeNode rootNode, T4Grammar grammar, Parser parser)
            {
                var includes = from n in rootNode.ChildNodes
                                   let segmentChild = n.ChildNodes.First()
                                   where segmentChild.Term == grammar.Directive
                                   let dir = segmentChild
                                   let dirName = grammar.GetDirectiveName(dir)
                                   where T4Grammar.IsEqualText(Convert.ToString(dirName), "include")
                                   select dir;
                var includeFiles = from incDir in includes
                                       let filepath = grammar.GetDirectiveAttributes(incDir)["File"]
                                       select new
                                   { DirectiveNode = incDir, File = GetIncludeFile(Convert.ToString(filepath)) };
                foreach (var incFile in includeFiles)
                {
                    //do not expand the same files, in case there's a multiple nested references to the same include files
                    if (_expandedFiles.Contains(incFile.File.FullName)) continue;
                    var text = File.ReadAllText(Convert.ToString(incFile.File.FullName));
                    var content = grammar.GetContentNode(parser.Parse(text));
                    incFile.DirectiveNode.Tag = new TranslationTag { ExpandedParseTreeNode = content };
                    //remember expanded file
                    _expandedFiles.Add(incFile.File.FullName);

                    //recursively process content from include file
                    ExpandIncludeFiles(content, grammar, parser);
                }
            }
        public T4Translator(ProjectItem projItem, T4Grammar grmr, Parser parsr)
        {
            _grammar = grmr;
            _parser = parsr;
            _projectItem = projItem;
            _rgenTranslation.Add(_grammar.AttributeName, new TranslationRule(
                new Dictionary<string, string>(T4Grammar.Comparer)
                {
                    { "language", "Language" },
                        { "extension", "DefaultExtension" },
                            { "namespace", "Namespace" }
                            }));
            _rgenTranslation.Add(_grammar.BeginSegment, new TranslationRule("<%"));
            _rgenTranslation.Add(_grammar.EndSegment, new TranslationRule("%>"));
            //remove Embedded class prefix
            _rgenTranslation.Add(_grammar.EmbeddedClassMemberPrefix, new TranslationRule(string.Empty));

            _getTranslatedTextTitleCaseTerms = new BnfTerm[] { _grammar.AttributeName, _grammar.DirectiveName };
        }
 public static void ExpandIncludeFiles(string dteVersion, ParseTreeNode rootNode, T4Grammar grammar, Parser parser)
 {
     var mgr = new IncludeFileManager(dteVersion);
     mgr.ExpandIncludeFiles(rootNode, grammar, parser);
 }