using System; using System.Web; using Umbraco.Core; using Umbraco.Core.Composing; namespace Umbraco.Web.Composing { /// /// Provides a base class for module injectors. /// /// The type of the injected module. public abstract class ModuleInjector : IHttpModule where TModule : IHttpModule { protected TModule Module { get; private set; } /// public void Init(HttpApplication context) { try { // using the service locator here - no other way, really Module = Current.Container.GetInstance(); Module.Init(context); } catch { var runtimeState = Current.Container.GetInstance(); if (runtimeState.BootFailedException != null) { throw new Exception("Failed to boot", runtimeState.BootFailedException); } } } /// public void Dispose() { Module?.Dispose(); } } }