// ----< demonstrates req #3e - view file text >-------------------- private void DemoGetFileText() { RepoClientState state = (RepoClientState)this.DataContext; state.ServerCommService.Requests.GetFileText("RepoCore", "SoftwareRepository", "RepoCore.h", 1, state.ServerConnProps.UserId, (GetFileTextResponse fileTextRes) => { Console.WriteLine($"\n\n{new String('-', 60)}"); Console.WriteLine($" Demonstrating Requirement #3e - Viewing full file text"); Console.WriteLine($"{new String('-', 60)}\n"); Console.WriteLine($" > Fetch for requestId [{fileTextRes.RequestId}] succeeded"); Console.WriteLine($" > Below are few lines of text from file RepoCore.h v1\n"); Console.WriteLine($" {new String('-', 15)}x{new String('-', 15)}"); Console.WriteLine($"\n{RepoFile.readFileText("RepoCore.h").Substring(0, 1025)}\n"); Console.WriteLine($" {new String('-', 15)}x{new String('-', 15)}"); Console.WriteLine($"\n Test Passed\n"); }, true); }
// ----< actions to be performed when the window is loaded >-------------------- private void FileTextPopup_Loaded(object sender, RoutedEventArgs e) { // clears any existing paragraphs from the embedded // file text viewer user control this.fileTextViewer.fileText.Blocks.Clear(); RepoClientState state = (RepoClientState)this.DataContext; RepoFile repoFile = state.BrowseProps.SelectedRepoFile; // query the repository for the file's text state.ServerCommService.Requests.GetFileText(repoFile.PackageName, repoFile.Namespace, repoFile.Filename, repoFile.Version, state.ServerConnProps.UserId, (GetFileTextResponse fileTextRes) => { // invoking through dispatcher because UI elements cannot // be set from external thread this.Dispatcher.Invoke(() => { // feeds the received file's contents to the file text viewer Paragraph para = new Paragraph(); para.Inlines.Add(new Run(RepoFile.readFileText(repoFile.Filename))); this.fileTextViewer.fileText.Blocks.Add(para); }); }, true); }