Esempio n. 1
0
        internal async static Task <Archive> Read(IAsset asset, ILogger logger)
        {
            IStreamable streamableAsset = asset.GetStreamable();

            if (streamableAsset == null)
            {
                throw new System.IO.InvalidDataException("Asset must be streamable to be read as an archive");
            }

            ArchiveType compression = FindCompression(asset);

            switch (compression)
            {
            case ArchiveType.Zip:
                var zipFile = Ionic.Zip.ZipFile.Read(await streamableAsset.GetStreamAsync());
                return(new ZipArchiveAsset(zipFile, asset, logger));

            case ArchiveType.TarGzip:
                return(new TarGzipArchive(asset, logger));

            default:
                throw new System.IO.InvalidDataException("Asset is not recognized as an archive");
            }
        }
Esempio n. 2
0
        public async static Task <string> ReadAsString(this IStreamable streamable)
        {
            StreamReader sr = new StreamReader(await streamable.GetStreamAsync());

            return(sr.ReadToEnd());
        }