Пример #1
0
        private GitHubBranch[] getGitHubBranches()
        {
            var url = new ApiUrl(_GuiState).GetBranchesApiUrl();

            using (var webClient = new WebClient())
            {
                webClient.Headers.Add("user-agent", Downloader.UA);
                var jsonData = webClient.DownloadString(url);
                return(JsonConvert.DeserializeObject <GitHubBranch[]>(jsonData));
            }
        }
        private GitHubBranch[] getGitHubBranches()
        {
            var url = new ApiUrl(_guiModelData).GetBranchesApiUrl();

            using (var webClient = new WebClient())
            {
                webClient.Headers.Add("user-agent", Downloader.UA);
                webClient.Headers.Add("Authorization", string.Format("Token {0}", _guiModelData.GitHubToken));
                var jsonData = webClient.DownloadString(url);
                return(JsonConvert.DeserializeObject <GitHubBranch[]>(jsonData));
            }
        }
        private GitHubEntry[] getGitHubEntries(string repositorySubDir, string branch)
        {
            var url = new ApiUrl(_GuiState).GetApiUrl(repositorySubDir, branch);

            using (var webClient = new WebClient())
            {
                webClient.Headers.Add("user-agent", Downloader.UA);
                webClient.Headers.Add("Authorization", string.Format("Token {0}", _GuiState.GitHubToken));
                var jsonData = webClient.DownloadString(url);
                return(JsonConvert.DeserializeObject <GitHubEntry[]>(jsonData));
            }
        }
Пример #4
0
        public void TestSetApiSegmentsWithUrlsContainingSpaces()
        {
            var viewModel = new MainWindowViewModel
            {
                GuiModelData =
                {
                    RepositoryFolderFullUrl =
                        "https://github.com/EdxStudents/W3C_HTML5.1x/tree/master/About%20W3C%20and%20the%20Web"
                }
            };

            Assert.AreEqual("EdxStudents", viewModel.GuiModelData.RepositoryOwner);
            Assert.AreEqual("W3C_HTML5.1x", viewModel.GuiModelData.RepositoryName);
            Assert.AreEqual("About W3C and the Web", viewModel.GuiModelData.RepositorySubDir);

            var actual = new ApiUrl(viewModel.GuiModelData).GetApiUrl(viewModel.GuiModelData.RepositorySubDir);
            Assert.AreEqual("https://api.github.com/repos/EdxStudents/W3C_HTML5.1x/contents/About%20W3C%20and%20the%20Web", actual);
        }
Пример #5
0
        public void TestSetApiSegmentsWithNormalUrls()
        {
            var viewModel = new MainWindowViewModel
            {
                GuiModelData =
                {
                    RepositoryFolderFullUrl =
                        "https://github.com/VahidN/KendoUI-Samples/tree/master/KendoUI02_MVC/Controllers"
                }
            };

            Assert.AreEqual("VahidN", viewModel.GuiModelData.RepositoryOwner);
            Assert.AreEqual("KendoUI-Samples", viewModel.GuiModelData.RepositoryName);
            Assert.AreEqual("KendoUI02_MVC/Controllers", viewModel.GuiModelData.RepositorySubDir);

            var actual = new ApiUrl(viewModel.GuiModelData).GetApiUrl(viewModel.GuiModelData.RepositorySubDir);
            Assert.AreEqual("https://api.github.com/repos/VahidN/KendoUI-Samples/contents/KendoUI02_MVC/Controllers", actual);
        }
 private GitHubEntry[] getGitHubEntries(string repositorySubDir)
 {
     var url = new ApiUrl(_guiModelData).GetApiUrl(repositorySubDir);
     using (var webClient = new WebClient())
     {
         webClient.Headers.Add("user-agent", Downloader.UA);
         webClient.Headers.Add("Authorization", string.Format("Token {0}", _guiModelData.GitHubToken));
         var jsonData = webClient.DownloadString(url);
         return JsonConvert.DeserializeObject<GitHubEntry[]>(jsonData);
     }
 }