/// <summary> /// Cleans up the current <see cref="IServiceLocator"/> associated with the context. /// </summary> public virtual void Dispose() { BladeList components = GetAllBlades(); if (components != null) { foreach (IBlade component in components) { try { //HACK: Yes, I know this is ugly but need to figure out how to best handle this component.Dispose(); } catch { //TODO: Add better handling for this exception } } } if (ServiceLocator == null) { return; } try { //TODO: Remove this piece since you'll be using the Factory method for injection. //HACK: Yes, I know this is ugly but need to figure out how to best handle this ServiceLocator.Dispose(); } catch { //TODO: Add better handling for this exception } }
public void ShouldDistroyDisposableTypes() { var locator = new ServiceLocator(); var disbposble = new TestClassWDispose(); locator.RegisterInstance <ITestClass, TestClassWDispose>(disbposble); var reslut = locator.Resolve <ITestClass>(); Assert.IsNotNull(reslut); locator.Dispose(); Assert.IsTrue(disbposble.Disposed); }
protected void Application_Stop() { ServiceLocator.Dispose(); }
protected override void OnExit(ExitEventArgs e) { base.OnExit(e); ServiceLocator.Dispose(); }