/// <summary> /// Called when the engine is shutting down. /// </summary> protected override void dispose(bool disposeManagedResources) { if (!isDisposed) { if (disposeManagedResources) { // Unload & delete resources in turn foreach (KeyValuePair <string, Archive> arch in _archives) { // Unload arch.Value.Unload(); // Find factory to destroy ArchiveFactory fac = _factories[arch.Value.Type]; if (fac == null) { // Factory not found throw ExceptionFactory.CreateFatalException("Cannot find an archive factory to deal with archive of type {0}", arch.Value.Type); } Archive tmp = arch.Value; fac.DestroyInstance(ref tmp); } // Empty the list _archives.Clear(); } // There are no unmanaged resources to release, but // if we add them, they need to be released here. } // If it is available, make the call to the // base class's Dispose(Boolean) method base.dispose(disposeManagedResources); }
/// <summary> /// Unloads an archive. /// </summary> /// <remarks> /// You must ensure that this archive is not being used before removing it. /// </remarks> /// <param name="arch">The Archive to unload</param> public void Unload(string filename) { Archive arch = _archives[filename]; if (arch != null) { arch.Unload(); ArchiveFactory fac = _factories[arch.Type]; if (fac == null) { throw ExceptionFactory.CreateFatalException("Cannot find an archive factory to deal with archive of type {0}", arch.Type); } _archives.Remove(arch.Name); fac.DestroyInstance(ref arch); } }