コード例 #1
0
ファイル: Attachment.cs プロジェクト: ahmed605/ZuneShell.dll
        private static Attachment CreateAttachmentFromMessage(
            MessageRoot message,
            MessageDetails messageDetails)
        {
            Attachment attachment = null;

            if (message != null)
            {
                string type = message.Type;
                if (message.MediaId != Guid.Empty)
                {
                    switch (type)
                    {
                    case "album":
                        attachment = new AlbumAttachment(message.MediaId, null, null, null, Guid.Empty);
                        break;

                    case "playlist":
                        attachment = new PlaylistAttachment(message.MediaId, null, null);
                        break;

                    case "podcast":
                        attachment = new PodcastAttachment(message.MediaId, null, null, null, null);
                        break;

                    case "song":
                        attachment = new TrackAttachment(message.MediaId, null, null, null);
                        break;

                    case "video":
                        attachment = new EpisodeAttachment(message.MediaId, null, null, null);
                        break;

                    case "movie":
                        attachment = new MovieAttachment(message.MediaId, null, null);
                        break;

                    case "movietrailer":
                        attachment = new TrailerAttachment(message.MediaId, null, null);
                        break;
                    }
                }
                else if (messageDetails != null)
                {
                    if (messageDetails.PodcastMediaId != Guid.Empty)
                    {
                        if (type == "podcast")
                        {
                            attachment = new PodcastAttachment(messageDetails.PodcastMediaId, null, null, null, null);
                        }
                    }
                    else if (!string.IsNullOrEmpty(messageDetails.ZuneTag) && type == "card")
                    {
                        attachment = new ProfileAttachment(messageDetails.ZuneTag, null, null);
                    }
                }
            }
            return(attachment);
        }
コード例 #2
0
ファイル: Attachment.cs プロジェクト: ahmed605/ZuneShell.dll
        private static Attachment CreateAttachment(
            Guid zuneMediaId,
            MediaType mediaType,
            int libraryId,
            string title,
            string url,
            VideoCategory videoCategory,
            MovieType movieType)
        {
            Attachment attachment = null;

            if (libraryId != -1 && mediaType == MediaType.Playlist)
            {
                attachment = new CollectionPlaylistAttachment(null, title, null, libraryId, null);
            }
            else
            {
                switch (mediaType)
                {
                case MediaType.Track:
                    if (zuneMediaId != Guid.Empty)
                    {
                        attachment = new TrackAttachment(zuneMediaId, title, null, null);
                        break;
                    }
                    break;

                case MediaType.Video:
                    if (zuneMediaId != Guid.Empty)
                    {
                        switch (videoCategory)
                        {
                        case VideoCategory.TV:
                            attachment = new EpisodeAttachment(zuneMediaId, title, null, null);
                            break;

                        case VideoCategory.Movies:
                            attachment = movieType != MovieType.Trailer ? new MovieAttachment(zuneMediaId, title, null) : (Attachment) new TrailerAttachment(zuneMediaId, title, null);
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                    break;

                case MediaType.Playlist:
                    if (zuneMediaId != Guid.Empty)
                    {
                        attachment = new PlaylistAttachment(zuneMediaId, title, null);
                        break;
                    }
                    break;

                case MediaType.Album:
                    if (zuneMediaId != Guid.Empty)
                    {
                        attachment = new AlbumAttachment(zuneMediaId, title, null, null, Guid.Empty);
                        break;
                    }
                    break;

                case MediaType.Podcast:
                    if (zuneMediaId != Guid.Empty || !string.IsNullOrEmpty(url))
                    {
                        attachment = new PodcastAttachment(zuneMediaId, title, null, url, null);
                        break;
                    }
                    break;
                }
            }
            return(attachment);
        }