Exemple #1
0
        private void MarkProjectForTextTemplating(IVsHierarchy hierarchy)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            Guid gUID = typeof(SSubSonicTemplatingService).GUID;
            IVsProjectStartupServices startUpServices = GetStartUpServices(hierarchy);

            if ((startUpServices != null) && !StartupServicesReferencesService(startUpServices, gUID))
            {
                ErrorHandler.Failed(startUpServices.AddStartupService(ref gUID));
                SqmFacade.T4MarkProjectForTextTemplating();
            }
        }
Exemple #2
0
        public string ProcessTemplate(string inputFile, string content, ITextTemplatingCallback callback = null, object hierarchy = null)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            string result = "";

            if (this is ITextTemplatingComponents SubSonicComponents)
            {
                SubSonicComponents.Hierarchy    = hierarchy;
                SubSonicComponents.Callback     = callback;
                SubSonicComponents.TemplateFile = inputFile;

                SubSonicComponents.Host.SetFileExtension(SearchForLanguage(content, "C#") ? ".cs" : ".vb");

                transformationHost.Session = transformationHost.CreateSession();

                result = SubSonicComponents.Engine.ProcessTemplate(content, SubSonicComponents.Host);

                if ((errorSessionDepth == 0) && MustUnloadAfterProcessingTemplate)
                {
                    MustUnloadAfterProcessingTemplate = false;
                    UnloadGenerationAppDomain();
                }

                // SqmFacade is a DTE wrapper that can send additional commands to VS
                if (SearchForLanguage(content, "C#"))
                {
                    SqmFacade.T4PreprocessTemplateCS();
                }
                else if (SearchForLanguage(content, "VB"))
                {
                    SqmFacade.T4PreprocessTemplateVB();
                }
            }

            return(result);
        }