private Node ReadAsset(AssetInfo assetInfo, Dictionary <string, Node> containers) { Node asset = NodeFactory.CreateContainer(assetInfo.Id); foreach (Models.FileInfo fileInfo in assetInfo.Files) { if (!containers.TryGetValue(fileInfo.ContainerId, out Node container)) { throw new DirectoryNotFoundException($"Container not found: {fileInfo.ContainerId}"); } Node file = Navigator.SearchNode(container, fileInfo.Path); if (file == null) { throw new FileNotFoundException($"File not found: {fileInfo.Name}"); } if (!ChecksumHelper.Check(file.Stream, fileInfo.Checksum)) { throw new ChecksumMismatchException($"Checksum mismatch in {fileInfo.Name}"); } file.Transform(fileInfo.Readers, Parameters); asset.Add(file); } asset.Transform(assetInfo.Mergers, Parameters); return(asset); }
private void ReadContainers(IList <ContainerInfo> containers, Node parent, Dictionary <string, Node> dictionary) { foreach (ContainerInfo containerInfo in containers) { Node node = Navigator.SearchNode(parent, containerInfo.Path); if (node == null) { throw new DirectoryNotFoundException($"Parent: {parent.Path} - Node: {containerInfo.Path}"); } if (!ChecksumHelper.Check(node.Stream, containerInfo.Checksum)) { throw new ChecksumMismatchException($"Checksum mismatch in {containerInfo.Name}"); } node.Transform(containerInfo.Readers, Parameters); dictionary.Add(containerInfo.Id, node); ReadContainers(containerInfo.Containers, node, dictionary); } }