예제 #1
0
        public static ComicVineResponseData GetFirstVolumeQueryResponse(string xmlString)
        {
            ComicVineResponseData comicVineResponseData = new ComicVineResponseData();

            XDocument xDocument = XDocument.Parse(xmlString, LoadOptions.None);

            comicVineResponseData.number_of_page_results  = StringUtilFunctions.TryToParse(XmlUtilFunctions.getNodeValue(xDocument, "number_of_page_results"));
            comicVineResponseData.number_of_total_results = StringUtilFunctions.TryToParse(XmlUtilFunctions.getNodeValue(xDocument, "number_of_total_results"));
            comicVineResponseData.limit = StringUtilFunctions.TryToParse(XmlUtilFunctions.getNodeValue(xDocument, "limit"));

            return(comicVineResponseData);
        }
예제 #2
0
        public static List <ComicVineVolume> GetVolumeQueryResponse(string xmlString)
        {
            List <ComicVineVolume> comicVineVolumeList = new List <ComicVineVolume>();

            XDocument xDocument = XDocument.Parse(xmlString, LoadOptions.None);

            var volumes = (from volume in xDocument.Descendants("results") select volume);

            foreach (var volume in volumes)
            {
                string name = volume.Descendants("name").First().Value;
                string id   = volume.Descendants("id").First().Value;

                comicVineVolumeList.Add(new ComicVineVolume()
                {
                    name = name,
                    id   = StringUtilFunctions.TryToParse(id),
                });
            }

            return(comicVineVolumeList);
        }
예제 #3
0
        public static ComicVineIssue GetIssue(string xmlString)
        {
            ComicVineIssue comicVineIssue = new ComicVineIssue();

            XDocument xDocument = XDocument.Parse(xmlString, LoadOptions.None);

            comicVineIssue.api_detail_url    = XmlUtilFunctions.getNodeValue(xDocument, "api_detail_url");
            comicVineIssue.issue_description = XmlUtilFunctions.getNodeValue(xDocument, "description");
            comicVineIssue.id = StringUtilFunctions.TryToParse(XmlUtilFunctions.getNodeValue(xDocument, "id"));

            // Get the volume images
            var             images          = from imgs in xDocument.Descendants("image") select imgs;
            ComicVineImages comicVineImages = new ComicVineImages();

            if (images != null | images.Count() > 0)
            {
                comicVineImages.icon_url   = images.Descendants("icon_url").First().Value;
                comicVineImages.medium_url = images.Descendants("medium_url").First().Value;
                comicVineImages.screen_url = images.Descendants("screen_url").First().Value;
                comicVineImages.small_url  = images.Descendants("small_url").First().Value;
                comicVineImages.super_url  = images.Descendants("super_url").First().Value;
                comicVineImages.thumb_url  = images.Descendants("thumb_url").First().Value;
                comicVineImages.tiny_url   = images.Descendants("tiny_url").First().Value;
            }

            comicVineIssue.images       = comicVineImages;
            comicVineIssue.issue_number = XmlUtilFunctions.getNodeValue(xDocument, "issue_number");
            comicVineIssue.name         = XmlUtilFunctions.getNodeValue(xDocument, "name");

            string comic_tentative_date = XmlUtilFunctions.getNodeValue(xDocument, "cover_date");

            comicVineIssue.issue_year  = StringUtilFunctions.TryToExtractYear(comic_tentative_date);
            comicVineIssue.issue_month = StringUtilFunctions.TryToExtractMonth(comic_tentative_date);



            // Get the volume details
            var volumes = from vols in xDocument.Descendants("volume") select vols;

            if (volumes != null & volumes.Count() > 0)
            {
                ComicVineVolume volum = new ComicVineVolume();
                volum.id              = StringUtilFunctions.TryToParse(volumes.Descendants("id").First().Value);
                volum.name            = volumes.Descendants("name").First().Value;
                volum.url             = volumes.Descendants("api_detail_url").First().Value;
                comicVineIssue.volume = volum;
            }



            var persons = from rols in xDocument.Descendants("person") select rols;
            List <ComicVineCredit> comicVineCreditList = new List <ComicVineCredit>();

            if (persons.Count() > 0)
            {
                foreach (var person in persons)
                {
                    ComicVineCredit comicVineCredit = new ComicVineCredit();
                    comicVineCredit.id             = StringUtilFunctions.TryToParse(person.Descendants("id").First().Value);
                    comicVineCredit.name           = person.Descendants("name").First().Value;
                    comicVineCredit.api_detail_url = person.Descendants("api_detail_url").First().Value;
                    comicVineCredit.role           = person.Descendants("role").First().Value;

                    comicVineCreditList.Add(comicVineCredit);
                }
            }

            comicVineIssue.credits = comicVineCreditList;

            var characters = from character in xDocument.Descendants("character") select character;
            List <ComicVineCharacter> comicVineCharacterList = new List <ComicVineCharacter>();

            if (characters.Count() > 0)
            {
                foreach (var tchar in characters)
                {
                    ComicVineCharacter comicVineCharacter = new ComicVineCharacter();
                    comicVineCharacter.id              = StringUtilFunctions.TryToParse(tchar.Descendants("id").First().Value);
                    comicVineCharacter.name            = tchar.Descendants("name").First().Value;
                    comicVineCharacter.api_detail_url  = tchar.Descendants("api_detail_url").First().Value;
                    comicVineCharacter.site_detail_url = tchar.Descendants("site_detail_url").First().Value;

                    comicVineCharacterList.Add(comicVineCharacter);
                }
            }

            comicVineIssue.characters = comicVineCharacterList;

            return(comicVineIssue);
        }
예제 #4
0
        public static ComicVineVolume GetVolume(string xmlString)
        {
            ComicVineVolume comicVineVolume = new ComicVineVolume();

            XDocument xDocument = XDocument.Parse(xmlString);

            comicVineVolume.url                = XmlUtilFunctions.getNodeValue(xDocument, "api_detail_url");
            comicVineVolume.count_of_issues    = StringUtilFunctions.TryToParse(XmlUtilFunctions.getNodeValue(xDocument, "count_of_issues"));
            comicVineVolume.volume_description = XmlUtilFunctions.getNodeValue(xDocument, "description");
            comicVineVolume.id = StringUtilFunctions.TryToParse(XmlUtilFunctions.getNodeValue(xDocument, "id"));


            ComicVineImages comicVineImages = new ComicVineImages();

            var images = from imgs in xDocument.Descendants("image") select imgs;

            if (images.Count() > 0)
            {
                try
                {
                    comicVineImages.icon_url   = images.Descendants("icon_url").First().Value;
                    comicVineImages.medium_url = images.Descendants("medium_url").First().Value;
                    comicVineImages.screen_url = images.Descendants("screen_url").First().Value;
                    comicVineImages.small_url  = images.Descendants("small_url").First().Value;
                    comicVineImages.super_url  = images.Descendants("super_url").First().Value;
                    comicVineImages.thumb_url  = images.Descendants("thumb_url").First().Value;
                    comicVineImages.tiny_url   = images.Descendants("tiny_url").First().Value;
                }
                catch (Exception ex)
                {
                }
            }

            comicVineVolume.images = comicVineImages;

            List <ComicVineIssue> comicVineIssueList = new List <ComicVineIssue>();

            var issues = from iss in xDocument.Descendants("issue") select iss;

            foreach (var issue in issues)
            {
                ComicVineIssue comicVineIssue = new ComicVineIssue();
                comicVineIssue.id             = StringUtilFunctions.TryToParse(issue.Descendants("id").First().Value);
                comicVineIssue.api_detail_url = issue.Descendants("api_detail_url").First().Value;
                comicVineIssue.name           = issue.Descendants("name").First().Value;
                comicVineIssue.issue_number   = issue.Descendants("issue_number").First().Value;

                comicVineIssueList.Add(comicVineIssue);
            }

            comicVineVolume.list_of_issue = comicVineIssueList;
            comicVineVolume.name          = XmlUtilFunctions.getNodeValue(xDocument, "name");

            ComicVinePublisher comicVinePublisher = new ComicVinePublisher();

            var publishers = from publ in xDocument.Descendants("publisher") select publ;

            if (publishers != null & publishers.Count() > 0)
            {
                try
                {
                    comicVinePublisher.publisher_name = publishers.Descendants("name").First().Value;
                    comicVinePublisher.publisher_id   = StringUtilFunctions.TryToParse(publishers.Descendants("id").First().Value);
                    comicVinePublisher.publisher_url  = publishers.Descendants("api_detail_url").First().Value;
                }
                catch (Exception ex)
                {
                }
            }

            comicVineVolume.publisher  = comicVinePublisher;
            comicVineVolume.start_year = StringUtilFunctions.TryToParse(XmlUtilFunctions.getNodeValue(xDocument, "start_year"));

            return(comicVineVolume);
        }
예제 #5
0
        private static ComicVineIssue Get(JObject j_ob, bool details)
        {
            ComicVineIssue comicVineIssue = new ComicVineIssue();

            comicVineIssue.id             = (int)j_ob["id"];
            comicVineIssue.api_detail_url = j_ob["api_detail_url"].ToString();

            ComicVineImages images = new ComicVineImages();

            if (!String.IsNullOrEmpty(j_ob["image"].ToString()))
            {
                try
                {
                    images = JsonConvert.DeserializeObject <ComicVineImages>(j_ob["image"].ToString());
                }
                catch (Exception ex)
                {
                    // We don't catch this exeption.
                }
            }

            comicVineIssue.images       = images;
            comicVineIssue.issue_number = j_ob["issue_number"].ToString();
            comicVineIssue.name         = j_ob["name"].ToString();

            string coverdate = j_ob["cover_date"].ToString();

            comicVineIssue.issue_year  = StringUtilFunctions.TryToExtractYear(coverdate);
            comicVineIssue.issue_month = StringUtilFunctions.TryToExtractMonth(coverdate);
            comicVineIssue.issue_title = j_ob["name"].ToString();

            ComicVineVolume volum = new ComicVineVolume();

            if (!String.IsNullOrEmpty(j_ob["volume"].ToString()))
            {
                volum = JsonConvert.DeserializeObject <ComicVineVolume>(j_ob["volume"].ToString());
            }

            comicVineIssue.volume = volum;

            if (details)
            {
                IList <JToken>            jCharacters            = j_ob["character_credits"].Children().ToList();
                IList <JToken>            jCredits               = j_ob["person_credits"].Children().ToList();
                List <ComicVineCharacter> comicVineCharacterList = new List <ComicVineCharacter>();
                List <ComicVineCredit>    comicVineCreditList    = new List <ComicVineCredit>();


                foreach (JToken character in jCharacters)
                {
                    ComicVineCharacter comicVineCharacter = JsonConvert.DeserializeObject <ComicVineCharacter>(character.ToString());
                    comicVineCharacterList.Add(comicVineCharacter);
                }

                foreach (JToken credit in jCredits)
                {
                    ComicVineCredit cc = JsonConvert.DeserializeObject <ComicVineCredit>(credit.ToString());
                    comicVineCreditList.Add(cc);
                }

                comicVineIssue.credits = new List <ComicVineCredit>();
                comicVineIssue.credits = comicVineCreditList;

                comicVineIssue.characters = new List <ComicVineCharacter>();
                comicVineIssue.characters = comicVineCharacterList;
            }



            return(comicVineIssue);
        }
예제 #6
0
        public static ComicVineVolume GetVolume(string jsonData)
        {
            ComicVineVolume detailedComicVineVolume = new ComicVineVolume();

            JObject jObject = JObject.Parse(jsonData);

            var results = jObject["results"]["publisher"];

            detailedComicVineVolume.url = jObject["results"]["api_detail_url"].ToString();

            string countOfIssues = jObject["results"]["count_of_issues"].ToString();

            detailedComicVineVolume.count_of_issues = StringUtilFunctions.TryToParse(countOfIssues);

            detailedComicVineVolume.volume_description = jObject["results"]["description"].ToString();

            string volumeId = jObject["results"]["id"].ToString();

            detailedComicVineVolume.id = StringUtilFunctions.TryToParse(volumeId);

            detailedComicVineVolume.name = jObject["results"]["name"].ToString();;

            string startYear = jObject["results"]["start_year"].ToString();

            detailedComicVineVolume.start_year = StringUtilFunctions.TryToParse(startYear);

            // Get the volume images
            //var timages = from imgs in xdoc.Descendants("image") select imgs;
            ComicVineImages images = new ComicVineImages();

            if (!String.IsNullOrEmpty(jObject["results"]["image"].ToString()))
            {
                try
                {
                    images = JsonConvert.DeserializeObject <ComicVineImages>(jObject["results"]["image"].ToString());
                }
                catch (Exception ex)
                {
                    // We don't catch this exeption.
                }
            }
            detailedComicVineVolume.images = images;

            // Get the collection of issues
            //List<ComicVineIssue> comicVineIssueList = new List<ComicVineIssue>();
            //IList<JToken> jIssues = jObject["results"]["issues"].Children().ToList();

            //foreach (JToken issues in jIssues)
            //{
            //    ComicVineIssue comicVineIssue = JsonConvert.DeserializeObject<ComicVineIssue>(issues.ToString());
            //    comicVineIssueList.Add(comicVineIssue);
            //}


            //detailedComicVineVolume.list_of_issue = comicVineIssueList;

            ComicVinePublisher publisher = new ComicVinePublisher();

            publisher = JsonConvert.DeserializeObject <ComicVinePublisher>(jObject["results"]["publisher"].ToString());

            detailedComicVineVolume.publisher = publisher;

            return(detailedComicVineVolume);
        }