コード例 #1
0
        private async Task GetRamlFromURL()
        {
            //StartProgress();
            //DoEvents();

            try
            {
                var url    = RamlOriginalSource;
                var result = includesManager.Manage(url, Path.GetTempPath(), Path.GetTempPath());

                var raml   = result.ModifiedContents;
                var parser = new RamlParser();

                var ramlDocument = await parser.LoadRamlAsync(raml, Path.GetTempPath());

                var filename = SetFilename(url);

                var path = Path.Combine(Path.GetTempPath(), filename);
                File.WriteAllText(path, raml);
                RamlTempFilePath   = path;
                RamlOriginalSource = url;

                SetPreview(ramlDocument);

                btnOk.IsEnabled = true;
                //StopProgress();
            }
            catch (UriFormatException uex)
            {
                ShowErrorAndDisableOk(uex.Message);
            }
            catch (HttpRequestException rex)
            {
                ShowErrorAndDisableOk(GetFriendlyMessage(rex));
                ActivityLog.LogError(VisualStudioAutomationHelper.RamlVsToolsActivityLogSource,
                                     VisualStudioAutomationHelper.GetExceptionInfo(rex));
            }
            catch (Exception ex)
            {
                ShowErrorAndDisableOk(ex.Message);
                ActivityLog.LogError(VisualStudioAutomationHelper.RamlVsToolsActivityLogSource,
                                     VisualStudioAutomationHelper.GetExceptionInfo(ex));
            }
        }
コード例 #2
0
        private async void GoButton_Click(object sender, RoutedEventArgs e)
        {
            StartProgress();
            DoEvents();

            try
            {
                var includesManager = new RamlIncludesManager();
                var url             = addressText.Text;
                var result          = includesManager.Manage(url, Path.GetTempPath());

                var raml   = result.ModifiedContents;
                var parser = new RamlParser();

                var ramlDocument = await parser.LoadRamlAsync(raml, Path.GetTempPath());

                var filename = Path.GetFileName(url);

                if (string.IsNullOrEmpty(filename))
                {
                    filename = "reference.raml";
                }

                if (!filename.ToLowerInvariant().EndsWith(RamlFileExtension))
                {
                    filename += RamlFileExtension;
                }

                txtFileName.Text = NetNamingMapper.RemoveIndalidChars(Path.GetFileNameWithoutExtension(filename)) + RamlFileExtension;

                var path = Path.Combine(Path.GetTempPath(), filename);
                File.WriteAllText(path, raml);
                RamlTempFilePath   = path;
                RamlOriginalSource = url;

                SetPreview(ramlDocument);

                btnOk.IsEnabled = true;
                StopProgress();
            }
            catch (UriFormatException uex)
            {
                ShowErrorAndStopProgress(uex.Message);
            }
            catch (HttpRequestException rex)
            {
                ShowErrorAndStopProgress(GetFriendlyMessage(rex));
                ActivityLog.LogError(VisualStudioAutomationHelper.RamlVsToolsActivityLogSource, VisualStudioAutomationHelper.GetExceptionInfo(rex));
            }
            catch (Exception ex)
            {
                ShowErrorAndStopProgress(ex.Message);
                ActivityLog.LogError(VisualStudioAutomationHelper.RamlVsToolsActivityLogSource, VisualStudioAutomationHelper.GetExceptionInfo(ex));
            }
        }
コード例 #3
0
		private static RamlIncludesManagerResult 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);

		    if (!result.IsSuccess) 
                return result;

		    UpdateRamlFile(ramlFilePath, result.ModifiedContents);

		    InstallerServices.AddNewIncludedFiles(result, includesFolderItem, destFolderItem);
		    return result;
		}