/// <summary>Immediately releases all resources used the GUI manager</summary> public void Dispose() { // Unregister the service if we have registered it before if (_gameServices != null) { var registeredService = _gameServices.GetService(typeof(IGuiService)); if (ReferenceEquals(registeredService, this)) { _gameServices.RemoveService(typeof(IGuiService)); } } // Dispose the input capturer, if necessary if (_inputCapturer != null) { var disposableInputCapturer = _inputCapturer as IDisposable; disposableInputCapturer?.Dispose(); _updateableInputCapturer = null; _inputCapturer = null; } // Dispose the GUI visualizer, if necessary if (_guiVisualizer != null) { var disposableguiVisualizer = _guiVisualizer as IDisposable; disposableguiVisualizer?.Dispose(); _updateableGuiVisualizer = null; _guiVisualizer = null; } }
protected virtual void Dispose(bool disposing) { if (!_isDisposed) { if (disposing) { if (_graphicsDeviceManager != null) { (_graphicsDeviceManager as GraphicsDeviceManager).Dispose(); _graphicsDeviceManager = null; } if (Platform != null) { Platform.Activated -= OnActivated; Platform.Deactivated -= OnDeactivated; _services.RemoveService(typeof(GamePlatform)); Platform.Dispose(); Platform = null; } } #if ANDROID Activity = null; #endif _isDisposed = true; _instance = null; } }
/// <summary> /// Removes and object of a type from the container. /// </summary> /// <typeparam name="T">The type of the object to remove.</typeparam> public static void Remove <T>() { if (_container.GetService(typeof(T)) != null) { _container.RemoveService(typeof(T)); } }
protected void AddServiceToGame(Type i_Type) { GameServiceContainer gameServices = this.Game.Services; if (gameServices.GetService(i_Type) != null) { gameServices.RemoveService(i_Type); } gameServices.AddService(i_Type, this); }
public void RemoveService() { string s = "Hello"; services.AddService(typeof(string), s); services.RemoveService(typeof(string)); string s2 = (string)services.GetService(typeof(string)); Assert.IsNull(s2); }
/// <summary>Immediately releases all resources and unregisters the component</summary> public virtual void Dispose() { // Unregister the service if we registered it to the game service container GameServiceContainer serviceContainer = this.serviceProvider as GameServiceContainer; if (serviceContainer != null) { object registeredService = serviceContainer.GetService( typeof(ISharedContentService) ); if (ReferenceEquals(registeredService, this)) { serviceContainer.RemoveService(typeof(ISharedContentService)); } } // Release all content stored in the content manager if (this.contentManager != null) { this.contentManager.Dispose(); this.contentManager = null; } }
public void Remove <T>() => services.RemoveService(typeof(T));
public static void Remove <T>() { Container.RemoveService(typeof(T)); }