示例#1
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (_fileProvider != null)
     {
         _fileProvider.Dispose();
     }
 }
示例#2
0
 public override void Dispose()
 {
     _documentRepository.Dispose();
     _documentTypeRepository.Dispose();
     _directoryService.Dispose();
     _fileRepository.Dispose();
     _fileProvider.Dispose();
 }
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         IFileProvider disposable = Interlocked.Exchange(ref _provider, null);
         if (disposable != null && _default != null)
         {
             // do not serialize the cache when autosaving the profile
             _default.Save(disposable, false);
             _default = null;
             disposable.Dispose();
         }
     }
 }
示例#4
0
        private void BtnLoad_Click(object sender, EventArgs e)
        {
            ContextMenu cm = new ContextMenu(new MenuItem[]
            {
                new MenuItem("APK", (s, e2) =>
                {
                    OpenFileDialog ofd = new OpenFileDialog()
                    {
                        CheckFileExists = true,
                        Title           = "Open Bundle File",
                        Multiselect     = false
                    };
                    if (ofd.ShowDialog() == DialogResult.Cancel)
                    {
                        return;
                    }
                    CloseStuff();
                    try
                    {
                        _fileProvider = new ZipFileProvider(ofd.FileName, FileCacheMode.Memory, false);
                        _manager      = new AssetsManager(_fileProvider, BSConst.KnownFiles.AssetsRootPath, BSConst.GetAssetTypeMap());
                        if (_fileProvider.FindFiles("globalgamemanagers").Count > 0)
                        {
                            _manager.GetAssetsFile("globalgamemanagers.assets");
                        }
                        if (_fileProvider.FindFiles("globalgamemanagers.assets*").Count > 0)
                        {
                            _manager.GetAssetsFile("globalgamemanagers.assets");
                        }
                        _manager.FindAndLoadAllAssets();
                        FillAssetsFiles();
                        this.Text = "Assets Explorer - " + Path.GetFileName(ofd.FileName);
                    }
                    catch (Exception ex)
                    {
                        Log.LogErr("Couldn't load APK!", ex);
                        MessageBox.Show("Failed to load!");
                        if (_fileProvider != null)
                        {
                            _fileProvider.Dispose();
                            _fileProvider = null;
                        }
                        return;
                    }
                }),
                new MenuItem("Folder", (s, e2) =>
                {
                    FolderBrowserDialog fbd = new FolderBrowserDialog()
                    {
                        ShowNewFolderButton = false,
                        Description         = "Select Assets Root Folder"
                    };
                    if (fbd.ShowDialog() == DialogResult.Cancel)
                    {
                        return;
                    }
                    CloseStuff();
                    try
                    {
                        _fileProvider = new FolderFileProvider(fbd.SelectedPath, false);
                        _manager      = new AssetsManager(_fileProvider, "", BSConst.GetAssetTypeMap());
                        if (_fileProvider.FindFiles("globalgamemanagers").Count > 0)
                        {
                            _manager.GetAssetsFile("globalgamemanagers.assets");
                        }
                        if (_fileProvider.FindFiles("globalgamemanagers.assets*").Count > 0)
                        {
                            _manager.GetAssetsFile("globalgamemanagers.assets");
                        }
                        _manager.FindAndLoadAllAssets();
                        FillAssetsFiles();
                        this.Text = "Assets Explorer - " + Path.GetFileName(fbd.SelectedPath);
                    }
                    catch (Exception ex)
                    {
                        Log.LogErr("Couldn't load folder!", ex);
                        MessageBox.Show("Failed to load!");
                        if (_fileProvider != null)
                        {
                            _fileProvider.Dispose();
                            _fileProvider = null;
                        }
                        return;
                    }
                }),
                new MenuItem("Bundle", (s, e2) =>
                {
                    OpenFileDialog ofd = new OpenFileDialog()
                    {
                        CheckFileExists = true,
                        Title           = "Open Bundle File",
                        Multiselect     = false
                    };
                    if (ofd.ShowDialog() == DialogResult.Cancel)
                    {
                        return;
                    }
                    CloseStuff();
                    try
                    {
                        _fileProvider = new BundleFileProvider(ofd.FileName, true);
                        _manager      = new AssetsManager(_fileProvider, "", BSConst.GetAssetTypeMap());
                        _manager.FindAndLoadAllAssets();
                        FillAssetsFiles();
                        this.Text = "Assets Explorer - " + Path.GetFileName(ofd.FileName);
                    }
                    catch (Exception ex)
                    {
                        Log.LogErr("Couldn't load bundle!", ex);
                        MessageBox.Show("Failed to load!");
                        if (_fileProvider != null)
                        {
                            _fileProvider.Dispose();
                            _fileProvider = null;
                        }
                        return;
                    }
                })
            });

            cm.Show(btnLoad, new Point(0, btnLoad.Height));
            return;
        }