internal VSManager(DynamicTextTransformation templatingHost) : base(templatingHost) { var hostServiceProvider = _textTransformation.Host.AsIServiceProvider(); if (hostServiceProvider == null) { throw new ArgumentNullException("Could not obtain hostServiceProvider"); } dte = (EnvDTE.DTE)hostServiceProvider.GetService(typeof(EnvDTE.DTE)); if (dte == null) { throw new ArgumentNullException("Could not obtain DTE from host"); } templateProjectItem = dte.Solution.FindProjectItem(templateFile); TemplateFileAsOutputTarget = new OutputTarget(templateProjectItem); //BuildOldTemplateProjectFilesToDelete(templateProjectItem); checkOutAction = (String fileName) => dte.SourceControl.CheckOutItem(fileName); projectSyncAction = (IEnumerable <FileBlock> generatedFiles) => ProjectSync(templateProjectItem, generatedFiles, oldProjectItemsToDelete); }
public static FileManager Create(object textTransformation) { FileManager result = null; bool inVSNET = false; DynamicTextTransformation transformation = DynamicTextTransformation.Create(textTransformation); IDynamicHost host = transformation.Host; try { #if !PREPROCESSED_TEMPLATE if (host.AsIServiceProvider() != null) { inVSNET = true; } #endif result = inVSNET ? new VSManager(transformation) : new FileManager(transformation); } catch (Exception e) { //host.LogError(e); } return(result); }
public CodeGenerationToolsForK2(object textTransformation) { if (textTransformation == null) { throw new ArgumentNullException("textTransformation"); } _textTransformation = DynamicTextTransformation.Create(textTransformation); _code = new CSharpCodeProvider(); _ef = new MetadataTools(_textTransformation); }
/// <summary> /// Initializes a new CodeGenerationTools object with the TextTransformation (T4 generated class) /// that is currently running /// </summary> public CodeGenerationTools(object textTransformation) { if (textTransformation == null) { throw new ArgumentNullException("textTransformation"); } _textTransformation = DynamicTextTransformation.Create(textTransformation); _code = new CSharpCodeProvider(); FullyQualifySystemTypes = false; CamelCaseFields = true; ActiveDTOStage = false; }
/// <summary> /// Creates an instance of the DynamicTextTransformation class around the passed in /// TextTransformation shapped instance passed in, or if the passed in instance /// already is a DynamicTextTransformation, it casts it and sends it back. /// </summary> public static DynamicTextTransformation Create(object instance) { if (instance == null) { throw new ArgumentNullException("instance"); } DynamicTextTransformation textTransformation = instance as DynamicTextTransformation; if (textTransformation != null) { return(textTransformation); } return(new DynamicTextTransformation(instance)); }
private FileManager(DynamicTextTransformation textTransformation) { this._textTransformation = textTransformation; this.templateFile = textTransformation.Host.TemplateFile; this.templateDirectory = Path.GetDirectoryName(templateFile); }