public async Task <Model> DownloadResourceAsync(DAL.Model model) { using (var webClient = new WebClient()) { if (model == null) { return(null); } try { var resultData = await webClient.DownloadDataTaskAsync(BuildDownloadUri(model)); using (var archiveStream = ArchiveFile.OpenArchiveStream(resultData)) { var loader = new Loader(); var modelResult = loader.LoadFromStream(archiveStream); return(modelResult); } } catch (WebException) { return(null); } catch (InvalidEnumArgumentException) { return(null); } } }
private Stream OpenTextureStream(Texture texture, byte[] resultData) { var extension = Path.GetExtension(texture.FileName); if (extension != null) { var fileExtension = extension.ToUpperInvariant(); switch (fileExtension) { case ".JPG": case ".PNG": case ".BMP": return(new MemoryStream(resultData)); case ".ZIP": return(ArchiveFile.OpenArchiveStream(resultData)); default: throw new InvalidDataException("The provided file format is not recognized."); } } return(null); }
private Stream OpenTextureStream(byte[] resultData) { return(ArchiveFile.OpenArchiveStream(resultData)); }