Exemplo n.º 1
0
        private Criteria <Artist> GetArtistCriteria(XElement xml)
        {
            var propertyName = (PropertyName)Enum.Parse(typeof(PropertyName), xml.Attribute(PlaylistCriteriaPropertyName).Value);
            var criteriaType = (CriteriaType)Enum.Parse(typeof(CriteriaType), xml.Attribute(PlaylistCriteriaType).Value);
            var valueString  = xml.Attribute(PlaylistCriteriaValue).Value;

            return(_trackCriteriaService.GetArtistCriteria(propertyName, criteriaType, valueString));
        }
Exemplo n.º 2
0
        private CriteriaPlaylist CreatePlaylist(CriteriaPlaylist playlist = null)
        {
            if (playlist == null)
            {
                playlist = new CriteriaPlaylist(0, "", false);
            }

            playlist.Title             = PlaylistTitle;
            playlist.OrderByProperty   = OrderByProperty;
            playlist.OrderByDescending = OrderByDescending;
            playlist.MaxTracks         = MaxTracks;

            playlist.CriteriaGroups.Clear();

            foreach (var group in Criteria.Where(g => g.Criteria.Any()))
            {
                var criteriaGroup = new CriteriaGroup();

                foreach (var criteria in group.Criteria.Where(g => g.PropertyName != null))
                {
                    switch (criteria.PropertyOwner)
                    {
                    case PropertyOwner.Track:
                        criteriaGroup.TrackCriteria.Add(_trackCriteriaService.GetTrackCriteria(criteria.PropertyName.Value, criteria.CriteriaType.Value, criteria.ValueString));
                        break;

                    case PropertyOwner.Disc:
                        criteriaGroup.DiscCriteria.Add(_trackCriteriaService.GetDiscCriteria(criteria.PropertyName.Value, criteria.CriteriaType.Value, criteria.ValueString));
                        break;

                    case PropertyOwner.Album:
                        criteriaGroup.AlbumCriteria.Add(_trackCriteriaService.GetAlbumCriteria(criteria.PropertyName.Value, criteria.CriteriaType.Value, criteria.ValueString));
                        break;

                    case PropertyOwner.Artist:
                        criteriaGroup.ArtistCriteria.Add(_trackCriteriaService.GetArtistCriteria(criteria.PropertyName.Value, criteria.CriteriaType.Value, criteria.ValueString));
                        break;

                    default:
                        throw new InvalidOperationException("Invalid property owner");
                    }
                }

                playlist.CriteriaGroups.Add(criteriaGroup);
            }

            return(playlist);
        }