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)); } }
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; }