public Comic(string path, string title, string author, string category, ComicMetadata?metadata = null) { var names = path.Split(System.IO.Path.DirectorySeparatorChar).Select(name => name.Trim()).ToArray(); if (names.Length < 2) { throw new ArgumentException("Invalid path: must have at least two levels"); } if (names[names.Length - 1] != title) { throw new ArgumentException("Invalid title: must be the name of the item's folder."); } if (names[names.Length - 2] != author) { throw new ArgumentException("Invalid author: must be the name of the item's parent folder."); } this.Path = path; this.Title = title; this.Author = author; this.Category = category; this.Metadata = metadata ?? new ComicMetadata(); }
public Comic WithMetadata(string?displayTitle = null, IEnumerable <string>?tags = null, bool?loved = null, string?thumbnailSource = null, string?dateAdded = null) { var metadata = new ComicMetadata { DisplayTitle = displayTitle ?? this.DisplayTitle, Loved = loved ?? this.Loved, ThumbnailSource = thumbnailSource ?? this.ThumbnailSource, DateAdded = dateAdded ?? this.DateAdded }; metadata.Tags.UnionWith(tags ?? this.Tags); return(this.With(metadata: metadata)); }