Esempio n. 1
0
        public GithubDocument(Stream document, ILinkFactory linkFactory)
        {
            var sr   = new StreamReader(document);
            var root = JToken.Load(new JsonTextReader(sr));

            _doc = root as JObject;
            if (_doc != null)
            {
                Load(linkFactory);
            }
            else
            {
                _List = root as JArray;
                Items = new List <GithubDocument>();
                foreach (JObject doc in _List)
                {
                    var childDoc = new GithubDocument(doc, linkFactory);
                    if (childDoc.Properties.ContainsKey("url"))
                    {
                        var itemUrl  = new Uri((string)childDoc.Properties["url"]);
                        var itemLink = linkFactory.CreateLink <ItemLink>();
                        itemLink.Target = itemUrl;
                        childDoc.Links.Add(itemLink.Relation, itemLink);
                    }
                    Items.Add(childDoc);
                }
            }
        }
Esempio n. 2
0
        public static UserResult InterpretResponse(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);
        }
Esempio n. 3
0
        public static CodeSearchResults InterpretResponse(GithubDocument document)
        {
            var results = new CodeSearchResults();

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

            return(results);
        }