public static AssetBundleArchive LoadAssetBundle(this ArchiveContainer container, string path, IStreamDecryptor decryptor)
 {
     using (var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read))
     {
         using (var stream = decryptor.Decrypt(fileStream))
         {
             AssetBundleArchive bundle = AssetBundleArchive.Load(stream);
             bundle.Path = path;
             container.AddBundleArchive(bundle);
             return(bundle);
         }
     }
 }
        protected virtual IEnumerator DoLoadAssetBundleFromStream(IProgressPromise <float, AssetBundle> promise)
        {
            if (!this.decryptor.AlgorithmName.Equals(this.BundleInfo.Encoding))
            {
                promise.UpdateProgress(0f);
                promise.SetException(new Exception(string.Format("The encryption algorithm '{0}' and decryption algorithm '{1}' does not match when decrypts Assetbundle {2}. ", this.BundleInfo.Encoding, this.decryptor.AlgorithmName, this.BundleInfo.Name)));
                yield break;
            }

            string path      = this.GetAbsoluteUri();
            long   totalSize = this.BundleInfo.FileSize;
            float  weight    = WEIGHT;

            if (this.IsRemoteUri())
            {
                string fullname = BundleUtil.GetStorableDirectory() + this.BundleInfo.Filename;
                using (UnityWebRequest www = new UnityWebRequest(path))
                {
                    www.downloadHandler = new DownloadFileHandler(fullname);
                    www.SendWebRequest();
                    while (!www.isDone)
                    {
                        if (www.downloadedBytes >= 0 && totalSize > 0)
                        {
                            promise.UpdateProgress(weight * (float)www.downloadedBytes / totalSize);
                        }
                        yield return(null);
                    }

                    if (!string.IsNullOrEmpty(www.error))
                    {
                        promise.SetException(new Exception(string.Format("Failed to load the AssetBundle '{0}' at the address '{1}'.Error:{2}", this.BundleInfo.Name, path, www.error)));
                        yield break;
                    }
                    path = fullname;
                }
            }
            else
            {
                weight = 0f;
                path   = this.GetAbsolutePath();
            }

            AssetBundleCreateRequest request = null;
            Stream stream = null;

            try
            {
                stream  = FileUtil.OpenRead(path);
                request = AssetBundle.LoadFromStreamAsync(decryptor.Decrypt(stream));
            }
            catch (Exception e)
            {
                if (stream != null)
                {
                    stream.Close();
                }

                promise.SetException(new Exception(string.Format("Failed to decrypt the AssetBundle '{0}' at the address '{1}'.Error:{2}", this.BundleInfo.Name, path, e)));
                yield break;
            }

            while (!request.isDone)
            {
                promise.UpdateProgress(weight + (1 - weight) * request.progress);
                yield return(null);
            }

            var assetBundle = request.assetBundle;

            if (assetBundle == null)
            {
                promise.SetException(new Exception(string.Format("Failed to load the AssetBundle '{0}' at the address '{1}'.", this.BundleInfo.Name, path)));
                yield break;
            }
            promise.UpdateProgress(1f);
            promise.SetResult(assetBundle);
        }