Exemple #1
0
        public static VideoRef Create(JsonElement element)
        {
            VideoRef member = new VideoRef();

            foreach (var property in element.EnumerateObject())
            {
                switch (property.Name)
                {
                case "duration":
                    member.Duration = property.Value.GetInt32();
                    break;

                case "embed":
                    member.Embed = property.Value.GetBoolean();
                    break;

                case "title":
                    member.Title = property.Value.GetString();
                    break;

                case "description":
                    member.Description = property.Value.GetString();
                    break;

                case "uri":
                    member.URL = property.Value.GetString();
                    break;

                default:
                    throw new Exception(string.Format("Unrecognised parameter when creating the Discogs VideoRef Object. Parameter is: {0}", property.Name));
                }
            }
            return(member);
        }
Exemple #2
0
        public static Master Create(JsonElement element)
        {
            var master = new Master();
            foreach (var property in element.EnumerateObject())
            {
                switch (property.Name)
                {
                    case "styles":
                        master.Styles = new List<string>();
                        foreach (var style in property.Value.EnumerateArray())
                        {
                            master.Styles.Add(style.GetString());
                        }
                        break;
                    case "genres":
                        master.Genres = new List<string>();
                        foreach (var genre in property.Value.EnumerateArray())
                        {
                            master.Genres.Add(genre.GetString());
                        }
                        break;
                    case "videos":
                        master.Videos = new List<VideoRef>();
                        foreach (var genre in property.Value.EnumerateArray())
                        {
                            master.Videos.Add(VideoRef.Create(genre));
                        }
                        break;
                    case "title":
                        master.Title = property.Value.GetString();
                        break;
                    case "main_release":
                        master.ReleaseId = property.Value.GetInt32();
                        break;
                    case "main_release_url":
                        master.ReleaseURI = property.Value.GetString();
                        break;
                    case "uri":
                        master.WebURL = property.Value.GetString();
                        break;
                    case "artists":
                        master.Artists = new List<ArtistRef>();
                        foreach (var artist in property.Value.EnumerateArray())
                        {
                            master.Artists.Add(ArtistRef.Create(artist));
                        }
                        break;
                    case "versions_url":
                        master.VersionsURI = property.Value.GetString();
                        break;
                    case "year":
                        master.Year = property.Value.GetInt32();
                        break;
                    case "images":
                        master.Images = new List<Image>();
                        foreach (var img in property.Value.EnumerateArray())
                        {
                            master.Images.Add(Image.Create(img));
                        }
                        break;
                    case "resource_url":
                        master.ResourceURI = property.Value.GetString();
                        break;
                    case "tracklist":
                        master.Tracklist = new List<TrackListItem>();
                        foreach (var track in property.Value.EnumerateArray())
                        {
                            master.Tracklist.Add(TrackListItem.Create(track));
                        }
                        break;
                    case "id":
                        master.Id = property.Value.GetInt32();
                        break;
                    case "num_for_sale":
                        master.NumberForSale = property.Value.GetInt32();
                        break;
                    case "lowest_price":
                        master.LowestPrice = property.Value.GetDouble();
                        break;
                    case "data_quality":
                        master.DataQulity = property.Value.GetString();
                        break;
                    default:
                        throw new ArgumentException("Unrecognised parameter when creating the Discogs Master Object.", property.Name);
                }
            }

            return master;
        }