Beispiel #1
0
        private void AddContractFromFile(string ramlFilePath, string targetNamespace, string ramlSource, bool?doNotScaffold, ProjectItem folderItem, string folderPath, string targetFilename)
        {
            InstallerServices.AddRefFile(ramlFilePath, targetNamespace, ramlSource, folderPath, targetFilename);

            var includesFolderPath = folderPath + Path.DirectorySeparatorChar + InstallerServices.IncludesFolderName;

            var includesManager = new RamlIncludesManager();
            var result          = includesManager.Manage(ramlSource, includesFolderPath, confirmOverrite: true);

            var includesFolderItem = folderItem.ProjectItems.Cast <ProjectItem>().FirstOrDefault(i => i.Name == InstallerServices.IncludesFolderName);

            if (includesFolderItem == null)
            {
                includesFolderItem = folderItem.ProjectItems.AddFolder(InstallerServices.IncludesFolderName);
            }

            foreach (var file in result.IncludedFiles)
            {
                includesFolderItem.ProjectItems.AddFromFile(file);
            }

            //var existingIncludeItems = includesFolderItem.ProjectItems.Cast<ProjectItem>();
            //var oldIncludedFiles = existingIncludeItems.Where(item => !result.IncludedFiles.Contains(item.FileNames[0]));
            //InstallerServices.RemoveSubItemsAndAssociatedFiles(oldIncludedFiles);

            var ramlProjItem = AddOrUpdateRamlFile(result.ModifiedContents, folderItem, folderPath, Path.GetFileName(ramlFilePath));

            InstallerServices.RemoveSubItemsAndAssociatedFiles(ramlProjItem);

            if (doNotScaffold == null || !doNotScaffold.Value)
            {
                Scaffold(ramlSource, targetNamespace, Path.GetFileName(ramlFilePath));
            }
        }
        private static void UpdateRamlAndIncludedFiles(string ramlFilePath, ProjectItem destFolderItem, string ramlSource, string containingFolder)
        {
            var includesFolderItem = destFolderItem.ProjectItems.Cast <ProjectItem>().FirstOrDefault(i => i.Name == InstallerServices.IncludesFolderName);

            InstallerServices.RemoveSubItemsAndAssociatedFiles(includesFolderItem);

            var includeManager = new RamlIncludesManager();
            var result         = includeManager.Manage(ramlSource, containingFolder + Path.DirectorySeparatorChar + InstallerServices.IncludesFolderName);

            UpdateRamlFile(ramlFilePath, result.ModifiedContents);

            InstallerServices.AddNewIncludedFiles(result, includesFolderItem, destFolderItem);
        }
        protected void AddContractFromFile(ProjectItem folderItem, string folderPath, RamlChooserActionParams parameters)
        {
            var includesFolderPath = folderPath + Path.DirectorySeparatorChar + InstallerServices.IncludesFolderName;

            var includesManager = new RamlIncludesManager();
            var result          = includesManager.Manage(parameters.RamlSource, includesFolderPath, confirmOverrite: true, rootRamlPath: folderPath + Path.DirectorySeparatorChar);

            ManageIncludes(folderItem, result);

            var ramlProjItem = AddOrUpdateRamlFile(result.ModifiedContents, folderItem, folderPath, parameters.TargetFileName);

            InstallerServices.RemoveSubItemsAndAssociatedFiles(ramlProjItem);

            var targetFolderPath = GetTargetFolderPath(folderPath, parameters.TargetFileName);

            RamlProperties props       = Map(parameters);
            var            refFilePath = InstallerServices.AddRefFile(parameters.RamlFilePath, targetFolderPath, parameters.TargetFileName, props);

            ramlProjItem.ProjectItems.AddFromFile(refFilePath);

            Scaffold(ramlProjItem.FileNames[0], parameters);
        }
Beispiel #4
0
        private void AddContractFromFile(ProjectItem folderItem, string folderPath, RamlChooserActionParams parameters)
        {
            var includesFolderPath = folderPath + Path.DirectorySeparatorChar + InstallerServices.IncludesFolderName;

            var includesManager = new RamlIncludesManager();
            var result          = includesManager.Manage(parameters.RamlSource, includesFolderPath, confirmOverrite: true, rootRamlPath: folderPath + Path.DirectorySeparatorChar);

            var includesFolderItem = folderItem.ProjectItems.Cast <ProjectItem>().FirstOrDefault(i => i.Name == InstallerServices.IncludesFolderName);

            if (includesFolderItem == null && !VisualStudioAutomationHelper.IsAVisualStudio2015Project(folderItem.ContainingProject))
            {
                includesFolderItem = folderItem.ProjectItems.AddFolder(InstallerServices.IncludesFolderName);
            }

            foreach (var file in result.IncludedFiles)
            {
                if (!VisualStudioAutomationHelper.IsAVisualStudio2015Project(folderItem.ContainingProject) || !File.Exists(file))
                {
                    includesFolderItem.ProjectItems.AddFromFile(file);
                }
            }

            //var existingIncludeItems = includesFolderItem.ProjectItems.Cast<ProjectItem>();
            //var oldIncludedFiles = existingIncludeItems.Where(item => !result.IncludedFiles.Contains(item.FileNames[0]));
            //InstallerServices.RemoveSubItemsAndAssociatedFiles(oldIncludedFiles);

            var ramlProjItem = AddOrUpdateRamlFile(result.ModifiedContents, folderItem, folderPath, parameters.TargetFileName);

            InstallerServices.RemoveSubItemsAndAssociatedFiles(ramlProjItem);

            var targetFolderPath = GetTargetFolderPath(folderPath, parameters.TargetFileName, folderItem.ContainingProject);

            RamlProperties props       = Map(parameters);
            var            refFilePath = InstallerServices.AddRefFile(parameters.RamlFilePath, targetFolderPath, parameters.TargetFileName, props);

            ramlProjItem.ProjectItems.AddFromFile(refFilePath);

            Scaffold(ramlProjItem.FileNames[0], parameters);
        }