Ejemplo n.º 1
0
        private ItemInfo(asapJson.JsonNode sourceNode, ItemsGetterUtil.Image owner)
        {
            this.Tags = new List <Tag>();
            foreach (var node in sourceNode.getValue_Object()["tags"].getValue_Array())
            {
                this.Tags.Add(new Tag(node));
            }

            this.Comments = new List <Comment>();
            var tmpComments = new List <Comment>();

            foreach (var node in sourceNode.getValue_Object()["comments"].getValue_Array())
            {
                tmpComments.Add(new Comment(node, this));
            }
            foreach (var it in tmpComments)
            {
                if (it.Parent == 0)
                {
                    this.Comments.Add(it);
                }
                else
                {
                    tmpComments.Find((obj) => obj.Id == it.Parent).Children.Add(it);
                }
            }

            this.Timestamp = ApiProvider.UnixTimestamp0.AddSeconds(sourceNode.getValue_Object()["ts"].getValue_Number());
            this.Cache     = sourceNode.getValue_Object()["cache"].getValue_String();
            this.Rt        = (long)sourceNode.getValue_Object()["rt"].getValue_Number();
            this.Qc        = (long)sourceNode.getValue_Object()["qc"].getValue_Number();

            this.Owner = owner;
        }
Ejemplo n.º 2
0
        public static async Task <ItemInfo> Fetch(ItemsGetterUtil.Image img, ApiProvider apiProvider)
        {
            string url = apiProvider.Api;

            url += "items/info?itemId=" + img.Id;

            var response = await apiProvider.Client.GetAsync(new Uri(url));

            asapJson.JsonNode responseNode = new asapJson.JsonNode(await response.Content.ReadAsStringAsync(), true);
            response.Dispose();
            return(new ItemInfo(responseNode, img));
        }