Exemplo n.º 1
0
        /// <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
            }
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 protected void Application_Stop()
 {
     ServiceLocator.Dispose();
 }
Exemplo n.º 4
0
        protected override void OnExit(ExitEventArgs e)
        {
            base.OnExit(e);

            ServiceLocator.Dispose();
        }