Esempio n. 1
0
        /// <inheritdoc />
        public void Dispose()
        {
            if (_disposed)
            {
                return;
            }
            _disposed = true;

            lock (_storageLock)
            {
                _db.Dispose();
                _pageFile.Dispose();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        public void Dispose()
        {
            _streamProvider.Dispose();
            _parser.Dispose();
            foreach (var processor in _processors)
            {
                processor.Dispose();
            }

            if (_start.HasValue)
            {
                var stop = DateTime.UtcNow;
                Log.Trace("RawFileProcessor.Dispose({0}): Elapsed {1}", Name, stop - _start);
            }
        }
        /// <summary>
        ///     Disposes the specified stream.
        /// </summary>
        /// <param name="disposing">if set to <c>true</c> [disposing].</param>
        private void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }
            _disposed = true;

            if (!disposing)
            {
                return;
            }

            _streamProvider.Dispose();
            _streamProvider = null;
        }
Esempio n. 4
0
 /// <inheritdoc />
 public void Dispose()
 {
     _db.Dispose();
     _pageFile.Dispose();
 }
Esempio n. 5
0
        public async Task <bool> StartGameAsync(GameSystemVM system, IFile file, IFolder rootFolder = null)
        {
            if (CoreRunner == null)
            {
                RootFrame.Navigate(typeof(GamePlayerPage));
            }
            else
            {
                await CoreRunner.UnloadGameAsync();
            }

            StreamProvider?.Dispose();
            StreamProvider = null;
            string virtualMainFilePath = null;

            if (!ArchiveExtensions.Contains(Path.GetExtension(file.Name)))
            {
                IStreamProvider streamProvider;
                GetStreamProviderAndVirtualPath(system, file, rootFolder, out streamProvider, out virtualMainFilePath);
                StreamProvider = streamProvider;
            }
            else
            {
                var archiveProvider = new ArchiveStreamProvider(VFS.RomPath, file);
                await archiveProvider.InitializeAsync();

                StreamProvider = archiveProvider;
                var entries = await StreamProvider.ListEntriesAsync();

                virtualMainFilePath = entries.FirstOrDefault(d => system.SupportedExtensions.Contains(Path.GetExtension(d)));
            }

            //Navigation should cause the player page to load, which in turn should initialize the core runner
            while (CoreRunner == null)
            {
                await Task.Delay(100);
            }

            if (virtualMainFilePath == null)
            {
                return(false);
            }

            system.Core.OpenFileStream  = OnCoreOpenFileStream;
            system.Core.CloseFileStream = OnCoreCloseFileStream;
            var loadSuccessful = false;

            try
            {
                loadSuccessful = await CoreRunner.LoadGameAsync(system.Core, virtualMainFilePath);
            }
            catch
            {
                await StopGameAsync();

                return(false);
            }

            if (loadSuccessful)
            {
                GameStarted(this);
            }
            else
            {
                await StopGameAsync();

                return(false);
            }

            return(loadSuccessful);
        }
Esempio n. 6
0
        public async Task <bool> StartGameAsync(GameSystemVM system, IFileInfo file, IDirectoryInfo rootFolder = null)
        {
            var core = system.Core;

            if (CoreRunner == null)
            {
                RootFrame.Navigate(GamePlayerPageType);
            }
            else
            {
                await CoreRunner.UnloadGameAsync();
            }

            StreamProvider?.Dispose();
            StreamProvider = null;
            string virtualMainFilePath = null;

            if (core.NativeArchiveSupport || !ArchiveExtensions.Contains(Path.GetExtension(file.Name)))
            {
                virtualMainFilePath = $"{VFSRomPath}{Path.DirectorySeparatorChar}{file.Name}";
                StreamProvider      = new SingleFileStreamProvider(virtualMainFilePath, file);
                if (rootFolder != null)
                {
                    virtualMainFilePath = file.FullName.Substring(rootFolder.FullName.Length + 1);
                    virtualMainFilePath = $"{VFSRomPath}{Path.DirectorySeparatorChar}{virtualMainFilePath}";
                    StreamProvider      = new FolderStreamProvider(VFSRomPath, rootFolder);
                }
            }
            else
            {
                var archiveProvider = new ArchiveStreamProvider(VFSRomPath, file);
                await archiveProvider.InitializeAsync();

                StreamProvider = archiveProvider;
                var entries = await StreamProvider.ListEntriesAsync();

                virtualMainFilePath = entries.FirstOrDefault(d => system.SupportedExtensions.Contains(Path.GetExtension(d)));
            }

            var systemFolder = await system.GetSystemDirectoryAsync();

            var systemProvider = new FolderStreamProvider(VFSSystemPath, systemFolder);
            var saveFolder     = await system.GetSaveDirectoryAsync();

            var saveProvider = new FolderStreamProvider(VFSSavePath, saveFolder);

            StreamProvider = new CombinedStreamProvider(new HashSet <IStreamProvider>()
            {
                StreamProvider, systemProvider, saveProvider
            });

            //Navigation should cause the player page to load, which in turn should initialize the core runner
            while (CoreRunner == null)
            {
                await Task.Delay(100);
            }

            if (virtualMainFilePath == null)
            {
                return(false);
            }

            var loadSuccessful = false;

            try
            {
                loadSuccessful = await CoreRunner.LoadGameAsync(core, virtualMainFilePath);
            }
            catch
            {
                await StopGameAsync();

                return(false);
            }

            if (loadSuccessful)
            {
                GameStarted?.Invoke(this);
            }
            else
            {
                await StopGameAsync();

                return(false);
            }

            return(loadSuccessful);
        }
Esempio n. 7
0
 public void Dispose()
 {
     _writeStream.Dispose();
     _provider.Dispose();
     _offsetWriteStream.Dispose();
 }