protected void WriteLog(ComicBookFile file, string action) { var reletivePath = file.Path.Replace(config.ComicRepositoryPath, string.Empty); action = string.IsNullOrEmpty(action) ? "" : $" - ({action})"; Console.WriteLine($"({PrecentDone()}) {file.Id} : {reletivePath}{action}"); }
public virtual void Apply(ComicBookFile comic, FileInfo file, IArchive archive, IEnumerable <IArchiveEntry> pages) { var context = new RegExInterigatorContext() { comic = comic, file = file, archive = archive, pages = pages }; foreach (var binder in setup) { binder(context); } foreach (var expression in resolvers) { var test = new Regex(expression.Key); var testValue = expression.Value(context); var matches = test.Matches(testValue); if (!Apply(comic, expression.Key, matches)) { break; } } foreach (var binder in cleanup) { binder(context); } }
public bool ApplyRemoveFound(ComicBookFile comic, MatchCollection matches) { for (var index = matches.Count - 1; index >= 0; index--) { comic.Name = comic.Name.Remove(matches[index].Index, matches[index].Length); } return(true); }
public bool ApplyYearAndMonth(ComicBookFile comic, MatchCollection matches) { var result = matches[0].Value; comic.Year = result.Substring(0, 4); comic.Month = result.Substring(5); return(false); }
public virtual bool Apply(ComicBookFile comic, string test, MatchCollection matches) { if (matches.Count > 0) { return(this.binders[test](comic, matches)); } return(true); }
public void Apply(ComicBookFile comic, FileInfo file, IArchive archive, IEnumerable <IArchiveEntry> pages) { var parts = comic.Name.Split(new[] { " - " }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length > 1) { comic.Name = parts[0]; comic.Title = parts[1]; } }
public void VolumeIsNotDefinedByDefault(string fileName, string volume) { var comicbook = new ComicBookFile() { OriginalName = fileName }; new VolumeInterigator().Apply(comicbook, null, null, null); Assert.Equal(volume, comicbook.Volume); }
public void VolumeIsNotDefined() { var comicbook = new ComicBookFile() { OriginalName = "File with No Volume" }; new VolumeInterigator().Apply(comicbook, null, null, null); Assert.True(string.IsNullOrEmpty(comicbook.Volume)); }
public override void Store(ComicBookFile file) { this.resolver.Store(file); }
public bool ApplyVolume(ComicBookFile comic, MatchCollection matches) { comic.Volume = matches[0].Value; return(true); }
public override void Store(ComicBookFile file) { this.Files.Add(file.Id, file); }
public void Apply(ComicBookFile comic, FileInfo file, IArchive archive, IEnumerable <IArchiveEntry> pages) { comic.Publisher = publisherMap.Where(n => comic.Path.Contains(n.Key)) .Select(n => n.Value) .FirstOrDefault() ?? string.Empty; }
public abstract void Store(ComicBookFile file);
public bool ApplyYear(ComicBookFile comic, MatchCollection matches) { comic.Year = matches[0].Value; return(true); }