Exemple #1
0
        public static List <BaseDbParameter> FromModification(BasePodcastModification modification, ModificationDto dto)
        {
            List <BaseDbParameter> parameters = new List <BaseDbParameter>();

            if (modification is EpisodeDescriptionFilterModification description)
            {
                parameters.Add(new StringParameter(description.Argument, parameters.Count));
                parameters.Add(new StringFilterMethodParameter(description.Method, parameters.Count));
                parameters.Add(new BoolParameter(description.CaseInvariant, parameters.Count));
            }
            else if (modification is EpisodeDurationFilterModification duration)
            {
                parameters.Add(new DurationFilterMethodParameter(duration.Method, parameters.Count));
                parameters.Add(new LongParameter(duration.Duration, parameters.Count));
            }
            else if (modification is EpisodePublishDateFilterModification publish)
            {
                parameters.Add(new DateTimeParameter(publish.Date, parameters.Count));
                parameters.Add(new DateTimeFilterMethodParameter(publish.Method, parameters.Count));
            }
            else if (modification is EpisodeTitleFilterModification title)
            {
                parameters.Add(new StringParameter(title.Argument, parameters.Count));
                parameters.Add(new StringFilterMethodParameter(title.Method, parameters.Count));
                parameters.Add(new BoolParameter(title.CaseInvariant, parameters.Count));
            }
            else if (modification is RemoveDuplicateEpisodesModification remove)
            {
                parameters.Add(new BoolParameter(remove.KeepFirstEpisode, parameters.Count));
                parameters.Add(new RemoveDuplicateEpisodesMethodParameter(remove.TimeFrame, parameters.Count));
            }
            else
            {
                throw new ArgumentException($"The type {modification.GetType()} is not yet implemented.");
            }

            return(parameters);
        }
Exemple #2
0
 /// <summary>
 /// Constructor for regular use
 /// </summary>
 public ModificationDto(BasePodcastModification modification)
 {
     this.TypeName = modification.GetType().FullName;
     Parameters    = BaseDbParameter.FromModification(modification, this);
 }