Ejemplo n.º 1
0
        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}");
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        public virtual bool Apply(ComicBookFile comic, string test, MatchCollection matches)
        {
            if (matches.Count > 0)
            {
                return(this.binders[test](comic, matches));
            }

            return(true);
        }
Ejemplo n.º 6
0
        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];
            }
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        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));
        }
Ejemplo n.º 9
0
 public override void Store(ComicBookFile file)
 {
     this.resolver.Store(file);
 }
Ejemplo n.º 10
0
 public bool ApplyVolume(ComicBookFile comic, MatchCollection matches)
 {
     comic.Volume = matches[0].Value;
     return(true);
 }
Ejemplo n.º 11
0
 public override void Store(ComicBookFile file)
 {
     this.Files.Add(file.Id, file);
 }
Ejemplo n.º 12
0
 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;
 }
Ejemplo n.º 13
0
 public abstract void Store(ComicBookFile file);
Ejemplo n.º 14
0
 public bool ApplyYear(ComicBookFile comic, MatchCollection matches)
 {
     comic.Year = matches[0].Value;
     return(true);
 }