internal PageContext([NotNull] MangaContext root, [NotNull] ProjectDirectoryListingProvider listing, [NotNull] PageId page) { this.name = root.Name; this.listing = listing; this.page = page; try { var serializer = new JsonSerializer(); serializer.Converters.Add(new CharacterTypeConverter(root.IdNameMapping)); using var file = listing.FileOpen(listing.GetCapturePath(page)); using var jsonReader = new JsonTextReader(file); var pageJson = serializer.Deserialize <PageJson>(jsonReader); captures = pageJson.Captures .Select((c, i) => { var guid = root.Map(page, c.Id).Some(); return(new CaptureContext(this, c, new Translation(c, guid), new CaptureId(page, c.Id))); }) .ToList(); } catch (FileNotFoundException) { this.captures = Array.Empty <CaptureContext>(); } catch (DirectoryNotFoundException) { this.captures = Array.Empty <CaptureContext>(); } }
internal ChapterContext(MangaContext root, ChapterId chapter, ProjectDirectoryListingProvider listing) { this.root = root; this.chapter = chapter; this.listing = listing; }
internal VolumeContext(MangaContext root, VolumeId volume, ProjectDirectoryListingProvider listing) { this.volume = volume; this.root = root; this.listing = listing; }