private static T LoadJsonDocument <T>(IReadOnlyArchiveEntry entry) { using var zipStream = entry.OpenRead(); using var sr = new StreamReader(zipStream); using var reader = new JsonTextReader(sr); var serializer = new JsonSerializer(); return(serializer.Deserialize <T>(reader)); }
internal PackageResource(PackageExplorer packageExplorer, PackageDirectory directory, IReadOnlyArchiveEntry contentEntry, PackageResourceMetadataModel metadataModel) { Explorer = packageExplorer; Directory = directory; Dependencies = new PackageResourceDependencies(packageExplorer, metadataModel); Tags = new PackageResourceTags(); Name = contentEntry.Name; string withoutData = contentEntry.FullName.Substring(5); FullName = withoutData; Content = new PackageResourceContent(packageExplorer, contentEntry.FullName, contentEntry); int dotIndex = contentEntry.FullName.LastIndexOf('.'); Extension = dotIndex != -1 ? contentEntry.FullName.Substring(dotIndex) : null; }
internal PackageResourceContent(PackageExplorer packageExplorer, string contentKey, IReadOnlyArchiveEntry zipArchiveEntry) { this.packageExplorer = packageExplorer; this.contentKey = contentKey; CompressedSize = zipArchiveEntry.CompressedSize; UncompressedSize = zipArchiveEntry.UncompressedSize; }