コード例 #1
0
ファイル: MediaItem.cs プロジェクト: MIliev11/Samples
 public static MediaItem From(string id, string name, string artistName, Artwork artwork, MediaType type)
 {
     return(new MediaItem {
         Id = id,
         Name = name,
         ArtistName = artistName,
         Artwork = artwork,
         Type = type
     });
 }
コード例 #2
0
ファイル: MediaItem.cs プロジェクト: MIliev11/Samples
        public static MediaItem From(NSDictionary json)
        {
            var id = json [JsonKeys.Id]?.ToString() ?? throw new SerializationException(JsonKeys.Id);

            var typeString = json [JsonKeys.Type]?.ToString() ?? throw new SerializationException(JsonKeys.Type);
            var type       = (MediaType)Enum.Parse(typeof(MediaType), typeString, true);

            var attributes = json [JsonKeys.Attributes] as NSDictionary ??
                             throw new SerializationException(JsonKeys.Attributes);
            var name = attributes [JsonKeys.Name]?.ToString() ?? throw new SerializationException(JsonKeys.Name);

            var artworkJson = attributes [JsonKeys.Artwork] as NSDictionary ??
                              throw new SerializationException(JsonKeys.Artwork);
            var artwork = Artwork.From(artworkJson);

            var artistName = attributes [JsonKeys.ArtistName]?.ToString() ?? string.Empty;

            return(From(id, name, artistName, artwork, type));
        }
コード例 #3
0
ファイル: MediaItem.cs プロジェクト: MIliev11/Samples
 public static MediaItem Create() => From(string.Empty, string.Empty, string.Empty, Artwork.Create(), MediaType.Songs);