public static CodeSearchResult Parse(GithubDocument document)
 {
     var result = new CodeSearchResult();
     foreach (var property in document.Properties)
     {
         switch (property.Key)
         {
             case "name":
                 result.Name = (string)property.Value;
                 break;
             case "path":
                 result.Path = (string)property.Value;
                 break;
             case "sha":
                 result.Sha = (string)property.Value;
                 break;
             case "url":
                 result.CodeFileLink = new CodeFileLink() {
                     Target = new Uri((string)property.Value)
                 };
                 break;
         }
     }
     return result;
 }
Beispiel #2
0
        public static UserResult InterpretMessageBody(GithubDocument document)
        {
            var result = new UserResult();
            foreach (var property in document.Properties)
            {
                switch (property.Key)
                {
                    case "login":
                        result.Login = (string) property.Value;
                        break;
                    case "following":
                        result.Following = (int)property.Value;
                        break;
                    case "followers":
                        result.Followers = (int)property.Value;
                        break;
                    case "hireable":
                        result.Hireable = (bool)property.Value;
                        break;
                }
            }

            foreach (var link in document.Links.Values)
            {
                if (link is AvatarLink)
                {
                    result.AvatarLink = (AvatarLink)link;
                }
            }
            return result;
        }
 public static CodeSearchResults Parse(GithubDocument document)
 {
     return new CodeSearchResults
     {
         Count = (int) document.Properties["total_count"],
         Items = document.Items.Select(CodeSearchResult.Parse).ToList()
     };
 }
        public static CodeSearchResults InterpretResponse(GithubDocument document)
        {
            var results = new CodeSearchResults();

            results.Count = (int)document.Properties["total_count"]; 

            return results;
        }
 public static CodeFile InterpretMessageBody(GithubDocument document)
 {
     var bytes = Convert.FromBase64String((string)document.Properties["content"]);
     return new CodeFile
     {
         
         Content = Encoding.UTF8.GetString(bytes,0, bytes.Length)
     };
 }
        private async Task HandleCodeSearchDocument(GithubDocument githubDocument)
        {
            var searchResults = CodeSearchLink.InterpretMessageBody(githubDocument);
            var fileLinks = searchResults.Items
                .Where(i => i.Name.Contains(_FileNameFilter) && i.CodeFileLink != null)
                .Select(i => i.CodeFileLink);

            foreach (var fileLink in fileLinks)
            {
                await _httpClient.FollowLinkAsync(fileLink).ApplyRepresentationToAsync(this);
            }
        }
 internal static HomeDocument Parse(GithubDocument githubDocument)
 {
     var home = new HomeDocument();
     foreach (var link in githubDocument.Links)
     {
         switch (link.Key)
         {
             case "code_search_url":
                 home.CodeSearchLink = (CodeSearchLink)link.Value;
                 break;
         }
     }
     return home;
 }
 private async Task HandleHomeDocument(GithubDocument githubDocument)
 {
     _CodeSearchLink = githubDocument.GetLink<CodeSearchLink>();
     _CodeSearchLink.Query = _Query;
     await _httpClient.FollowLinkAsync(_CodeSearchLink).ApplyRepresentationToAsync(this);
 }
 private async Task HandleStandardDocumentResponse(string link, HttpResponseMessage responseMessage)
 {
     _lastDocument = await responseMessage.Content.ReadAsGithubDocumentAsync(_linkFactory);
 }
 private async Task HandleUserLinkResponse(string link, HttpResponseMessage responseMessage)
 {
     _lastDocument = await responseMessage.Content.ReadAsGithubDocumentAsync(_linkFactory);
     _currentUser = UserLink.InterpretMessageBody(_lastDocument);
 }
 private async Task HandleHomeLinkResponse(string link, HttpResponseMessage responseMessage)
 {
     _homeDocument = await responseMessage.Content.ReadAsGithubDocumentAsync(_linkFactory);
     _lastDocument = HomeDocument;
 }
Beispiel #12
0
 private async Task HandleStandardDocumentResponse(Link link, HttpResponseMessage responseMessage)
 {
     _lastDocument = await responseMessage.Content.ReadAsGithubDocumentAsync(_linkFactory);
 }
Beispiel #13
0
        private async Task HandleUserLinkResponse(Link link, HttpResponseMessage responseMessage)
        {
            _lastDocument = await responseMessage.Content.ReadAsGithubDocumentAsync(_linkFactory);

            _currentUser = UserLink.InterpretResponse(_lastDocument);
        }
Beispiel #14
0
        private async Task HandleHomeLinkResponse(Link link, HttpResponseMessage responseMessage)
        {
            _homeDocument = await responseMessage.Content.ReadAsGithubDocumentAsync(_linkFactory);

            _lastDocument = HomeDocument;
        }
 private void HandleCodeFileDocument(GithubDocument githubDocument)
 {
     // Use Type Specific Link to interpret results
     var codeFile = CodeFileLink.InterpretMessageBody(githubDocument);
     FileContents.Add(codeFile.Content);
 }
Beispiel #16
0
 public HomeDocument InterpretMessageBody(GithubDocument githubDocument)
 {
     return HomeDocument.Parse(githubDocument);
 }
 public static CodeSearchResults InterpretMessageBody(GithubDocument document)
 {
     return CodeSearchResults.Parse(document);
 }