public void UpdateRaml(string ramlFilePath) { var dte = ServiceProvider.GetService(typeof(SDTE)) as DTE; var proj = VisualStudioAutomationHelper.GetActiveProject(dte); var contractsFolderPath = Path.GetDirectoryName(proj.FullName) + Path.DirectorySeparatorChar + ContractsFolderName + Path.DirectorySeparatorChar; var refFilePath = InstallerServices.GetRefFilePath(ramlFilePath); var includesFolderPath = contractsFolderPath + Path.DirectorySeparatorChar + InstallerServices.IncludesFolderName; var ramlSource = RamlReferenceReader.GetRamlSource(refFilePath); if (string.IsNullOrWhiteSpace(ramlSource)) { ramlSource = ramlFilePath; } var includesManager = new RamlIncludesManager(); var result = includesManager.Manage(ramlSource, includesFolderPath, contractsFolderPath + Path.DirectorySeparatorChar); if (result.IsSuccess) { File.WriteAllText(ramlFilePath, result.ModifiedContents); var parameters = new RamlChooserActionParams(ramlFilePath, ramlFilePath, null, null, Path.GetFileName(ramlFilePath).ToLowerInvariant(), RamlReferenceReader.GetRamlNamespace(refFilePath), null) { UseAsyncMethods = RamlReferenceReader.GetRamlUseAsyncMethods(refFilePath), IncludeApiVersionInRoutePrefix = RamlReferenceReader.GetRamlIncludeApiVersionInRoutePrefix(refFilePath), ModelsFolder = RamlReferenceReader.GetModelsFolder(refFilePath), ImplementationControllersFolder = RamlReferenceReader.GetImplementationControllersFolder(refFilePath), AddGeneratedSuffixToFiles = RamlReferenceReader.GetAddGeneratedSuffix(refFilePath) }; Scaffold(ramlFilePath, parameters); } }
private static void ScaffoldMainRamlFiles(IEnumerable <string> ramlFiles) { var service = GetRamlScaffoldService(Microsoft.VisualStudio.Shell.ServiceProvider.GlobalProvider); foreach (var ramlFile in ramlFiles) { var refFilePath = InstallerServices.GetRefFilePath(ramlFile); var includeApiVersionInRoutePrefix = RamlReferenceReader.GetRamlIncludeApiVersionInRoutePrefix(refFilePath); var parameters = new RamlChooserActionParams(ramlFile, ramlFile, null, null, Path.GetFileName(ramlFile), RamlReferenceReader.GetRamlNamespace(refFilePath), null) { UseAsyncMethods = RamlReferenceReader.GetRamlUseAsyncMethods(refFilePath), IncludeApiVersionInRoutePrefix = includeApiVersionInRoutePrefix, ModelsFolder = RamlReferenceReader.GetModelsFolder(refFilePath), ImplementationControllersFolder = RamlReferenceReader.GetImplementationControllersFolder(refFilePath), AddGeneratedSuffixToFiles = RamlReferenceReader.GetAddGeneratedSuffix(refFilePath) }; service.Scaffold(ramlFile, parameters); } }