コード例 #1
0
        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);
                }
            }
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 private Stream OpenTextureStream(byte[] resultData)
 {
     return(ArchiveFile.OpenArchiveStream(resultData));
 }