Exemplo n.º 1
0
        static Art.Object MakeArtObject(SearchResult.Record record)
        {
            if (string.IsNullOrEmpty(record.primaryimageurl) ||
                string.IsNullOrEmpty(record.url) ||
                record.imagepermissionlevel != (int)ImagePermissionLevel.DisplayAtAnySize)
            {
                return(null);
            }

            return(new Art.Object {
                imageURL = record.primaryimageurl, listingURL = record.url, artSourceHashTag = "#harvardartmuseums"
            });
        }
Exemplo n.º 2
0
        static Art.Object GetRandomObject(string apiKey, System.Random random)
        {
            string classification = GetRandomClassification();

            System.Console.WriteLine("Classification: " + classification);

            SearchResult pageCountResult = Web.GetWebResponse <SearchResult>(GetAPIURL(apiKey, classification));

            int randomPage = random.Next(pageCountResult.info.pages) + 1;

            System.Console.WriteLine(string.Format("Choosing page {0} out of {1}", randomPage, pageCountResult.info.pages));

            SearchResult randomPageResult = Web.GetWebResponse <SearchResult>(GetAPIURL(apiKey, classification, randomPage));

            SearchResult.Record randomRecord = randomPageResult.records.RandomElement(random);

            return(new Art.Object {
                imageURL = randomRecord.primaryimageurl, listingURL = randomRecord.url, artSourceHashTag = "#harvardartmuseums"
            });
        }