Exemple #1
0
 public async Task <Stream> GetDownloadStream()
 {
     using (var client = PluginMetadataCollection.GetClient())
     {
         return(string.IsNullOrWhiteSpace(DownloadUrl) ? null : await client.GetStreamAsync(DownloadUrl));
     }
 }
        public static PluginMetadataCollection FromStream(Stream stream)
        {
            var memStream = new MemoryStream();

            stream.CopyTo(memStream);

            using (memStream)
                using (var gzipStream = new GZipInputStream(memStream))
                    using (var archive = TarArchive.CreateInputTarArchive(gzipStream, null))
                    {
                        string hash     = CalculateSHA256(memStream);
                        string cacheDir = Path.Join(AppInfo.Current.CacheDirectory, $"{hash}-OpenTabletDriver-PluginMetadata");

                        if (Directory.Exists(cacheDir))
                        {
                            Directory.Delete(cacheDir, true);
                        }
                        archive.ExtractContents(cacheDir);

                        var collection         = EnumeratePluginMetadata(cacheDir);
                        var metadataCollection = new PluginMetadataCollection(collection);

                        return(metadataCollection);
                    }
        }
        public static PluginMetadataCollection FromStream(Stream stream)
        {
            using (var gzipStream = new GZipInputStream(stream))
                using (var archive = TarArchive.CreateInputTarArchive(gzipStream, null))
                {
                    // TODO: Properly cache instead of storing in the temporary directory
                    string cacheDir = Path.Join(AppInfo.Current.TemporaryDirectory, Guid.NewGuid().ToString());

                    archive.ExtractContents(cacheDir);
                    var collection         = EnumeratePluginMetadata(cacheDir);
                    var metadataCollection = new PluginMetadataCollection(collection);

                    if (Directory.Exists(cacheDir))
                    {
                        Directory.Delete(cacheDir, true);
                    }

                    return(metadataCollection);
                }
        }