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 MangaContext(MetadataJson metadata, ProjectDirectoryListingProvider listing) { this.listing = listing; this.metadata = metadata; using var file = listing.FileOpen(listing.GetCharactersPath()); using var jsonReader = new JsonTextReader(file); var serializer = new JsonSerializer(); this.charactersJson = serializer.Deserialize <CharactersJson>(jsonReader); IdNameMapping = new DualDictionary <long, string>(charactersJson.Characters .ToDictionary(c => c.Id, c => c.Name)); this.characterTypeConverter = new CharacterTypeConverter(IdNameMapping); }
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; }