/// <summary> /// This function is the callback used to execute a command when the a menu item is clicked. /// See the Initialize method to see how the menu item is associated to this function using /// the OleMenuCommandService service and the MenuCommand class. /// </summary> private void CSharpAddReferenceCallback(object sender, EventArgs e) { var t4TemplateBase = Resources.ServiceModelTemplate; var project = VSIXUtils.GetSelectedProject(); string projectPath = project.Properties.Item("FullPath").Value.ToString(); int fileNameNumber = 1; //Find a version of the default name that doesn't already exist, //mimicing VS default file name behaviour. while (File.Exists(Path.Combine(projectPath, "ServiceReference" + fileNameNumber + ".tt"))) { fileNameNumber++; } var dialog = new AddServiceStackReference("ServiceReference" + fileNameNumber); dialog.UseCSharpProvider(t4TemplateBase); dialog.ShowDialog(); if (!dialog.AddReferenceSucceeded) { return; } string templateCode = dialog.CodeTemplate; CreateAndAddTemplateToProject(dialog.FileNameTextBox.Text + ".tt", templateCode); }
private void AddServiceStackReference(string folderPath, INativeTypesHandler typesHandler) { int fileNameNumber = 1; //Find a version of the default name that doesn't already exist, //mimicing VS default file name behaviour. while (File.Exists(Path.Combine(folderPath, "ServiceReference" + fileNameNumber + typesHandler.CodeFileExtension))) { fileNameNumber++; } var dialog = new AddServiceStackReference("ServiceReference" + fileNameNumber, typesHandler); dialog.ShowDialog(); if (!dialog.AddReferenceSucceeded) { return; } string templateCode = dialog.CodeTemplate; AddNewDtoFileToProject(dialog.FileNameTextBox.Text + typesHandler.CodeFileExtension, templateCode, typesHandler.RequiredNuGetPackages); }