コード例 #1
0
        private static ProjectItem AddOrUpdateRamlFile(string modifiedContents, ProjectItem folderItem, string folderPath, string ramlFileName)
        {
            ProjectItem ramlProjItem;
            var         ramlDestFile = Path.Combine(folderPath, ramlFileName);

            if (File.Exists(ramlDestFile))
            {
                var dialogResult = InstallerServices.ShowConfirmationDialog(ramlFileName);

                if (dialogResult == MessageBoxResult.Yes)
                {
                    File.WriteAllText(ramlDestFile, modifiedContents);
                    ramlProjItem = folderItem.ProjectItems.AddFromFile(ramlDestFile);
                }
                else
                {
                    ramlProjItem = folderItem.ProjectItems.Cast <ProjectItem>().FirstOrDefault(i => i.Name == ramlFileName);
                    if (ramlProjItem == null)
                    {
                        ramlProjItem = folderItem.ProjectItems.AddFromFile(ramlDestFile);
                    }
                }
            }
            else
            {
                File.WriteAllText(ramlDestFile, modifiedContents);
                ramlProjItem = folderItem.ProjectItems.AddFromFile(ramlDestFile);
            }
            return(ramlProjItem);
        }
コード例 #2
0
        private static ProjectItem AddOrUpdateRamlFile(string modifiedContents, ProjectItem folderItem, string folderPath, string ramlFileName)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            ProjectItem ramlProjItem;
            var         ramlDestFile = Path.Combine(folderPath, ramlFileName);

            if (File.Exists(ramlDestFile))
            {
                var dialogResult = InstallerServices.ShowConfirmationDialog(ramlFileName);

                if (dialogResult == MessageBoxResult.Yes)
                {
                    File.WriteAllText(ramlDestFile, modifiedContents);
                    ramlProjItem = folderItem.ProjectItems.AddFromFile(ramlDestFile);
                }
                else
                {
#pragma warning disable VSTHRD010 // Invoke single-threaded types on Main thread
                    ramlProjItem = folderItem.ProjectItems.Cast <ProjectItem>().FirstOrDefault(i => i.Name == ramlFileName);
#pragma warning restore VSTHRD010 // Invoke single-threaded types on Main thread
                    if (ramlProjItem == null)
                    {
                        ramlProjItem = folderItem.ProjectItems.AddFromFile(ramlDestFile);
                    }
                }
            }
            else
            {
                File.WriteAllText(ramlDestFile, modifiedContents);
                ramlProjItem = folderItem.ProjectItems.AddFromFile(ramlDestFile);
            }
            return(ramlProjItem);
        }
コード例 #3
0
        private void AddEmptyContract(string filename, string title, ProjectItem folderItem, string folderPath, string targetNamespace, string targetFilename)
        {
            var newContractFile = Path.Combine(folderPath, filename);
            var contents        = CreateNewRamlContents(title);

            InstallerServices.AddRefFile(newContractFile, targetNamespace, newContractFile, folderPath, targetFilename);

            if (File.Exists(newContractFile))
            {
                var dialogResult = InstallerServices.ShowConfirmationDialog(filename);
                if (dialogResult == MessageBoxResult.Yes)
                {
                    File.WriteAllText(newContractFile, contents);
                    folderItem.ProjectItems.AddFromFile(newContractFile);
                }
                else
                {
                    var item = folderItem.ProjectItems.Cast <ProjectItem>().FirstOrDefault(i => i.Name == newContractFile);
                    if (item == null)
                    {
                        folderItem.ProjectItems.AddFromFile(newContractFile);
                    }
                }
            }
            else
            {
                File.WriteAllText(newContractFile, contents);
                folderItem.ProjectItems.AddFromFile(newContractFile);
            }
        }
コード例 #4
0
        protected void AddEmptyContract(ProjectItem folderItem, string folderPath, RamlChooserActionParams parameters)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            var newContractFile = Path.Combine(folderPath, parameters.TargetFileName);
            var contents        = CreateNewRamlContents(parameters.RamlTitle);

            ProjectItem ramlProjItem;

            if (File.Exists(newContractFile))
            {
                var dialogResult = InstallerServices.ShowConfirmationDialog(parameters.TargetFileName);
                if (dialogResult == MessageBoxResult.Yes)
                {
                    File.WriteAllText(newContractFile, contents);
                    ramlProjItem = folderItem.ProjectItems.AddFromFile(newContractFile);
                }
                else
                {
#pragma warning disable VSTHRD010 // Invoke single-threaded types on Main thread
                    ramlProjItem = folderItem.ProjectItems.Cast <ProjectItem>().FirstOrDefault(i => i.Name == newContractFile);
#pragma warning restore VSTHRD010 // Invoke single-threaded types on Main thread
                    if (ramlProjItem == null)
                    {
                        ramlProjItem = folderItem.ProjectItems.AddFromFile(newContractFile);
                    }
                }
            }
            else
            {
                File.WriteAllText(newContractFile, contents);
                ramlProjItem = folderItem.ProjectItems.AddFromFile(newContractFile);
            }

            var props            = Map(parameters);
            var targetFolderPath = GetTargetFolderPath(folderPath, parameters.TargetFileName);
            var refFilePath      = InstallerServices.AddRefFile(newContractFile, targetFolderPath, parameters.TargetFileName, props);
            ramlProjItem.ProjectItems.AddFromFile(refFilePath);
        }
コード例 #5
0
        protected void AddEmptyContract(ProjectItem folderItem, string folderPath, RamlChooserActionParams parameters)
        {
            var newContractFile = Path.Combine(folderPath, parameters.TargetFileName);
            var contents        = CreateNewRamlContents(parameters.RamlTitle);

            ProjectItem ramlProjItem;

            if (File.Exists(newContractFile))
            {
                var dialogResult = InstallerServices.ShowConfirmationDialog(parameters.TargetFileName);
                if (dialogResult == MessageBoxResult.Yes)
                {
                    File.WriteAllText(newContractFile, contents);
                    ramlProjItem = folderItem.ProjectItems.AddFromFile(newContractFile);
                }
                else
                {
                    ramlProjItem = folderItem.ProjectItems.Cast <ProjectItem>().FirstOrDefault(i => i.Name == newContractFile);
                    if (ramlProjItem == null)
                    {
                        ramlProjItem = folderItem.ProjectItems.AddFromFile(newContractFile);
                    }
                }
            }
            else
            {
                File.WriteAllText(newContractFile, contents);
                ramlProjItem = folderItem.ProjectItems.AddFromFile(newContractFile);
            }

            var props            = Map(parameters);
            var targetFolderPath = GetTargetFolderPath(folderPath, parameters.TargetFileName);
            var refFilePath      = InstallerServices.AddRefFile(newContractFile, targetFolderPath, parameters.TargetFileName, props);

            ramlProjItem.ProjectItems.AddFromFile(refFilePath);
        }