public override ServiceHostBase CreateServiceHost(string constructorString, Uri[] baseAddresses) { IComponentRegistration registration; if (constructorString == null) { throw new ArgumentNullException("constructorString"); } if (constructorString == string.Empty) { throw new ArgumentOutOfRangeException("constructorString"); } if (HostContainer == null) { throw new InvalidOperationException(); } // Create work context IRunningShellTable runningShellTable = HostContainer.Resolve <IRunningShellTable>(); ShellSettings shellSettings = runningShellTable.Match(baseAddresses.First().Host, baseAddresses.First().LocalPath); IBoyingHost BoyingHost = HostContainer.Resolve <IBoyingHost>(); ShellContext shellContext = BoyingHost.GetShellContext(shellSettings); IWorkContextAccessor workContextAccessor = shellContext.LifetimeScope.Resolve <IWorkContextAccessor>(); WorkContext workContext = workContextAccessor.GetContext(); if (workContext == null) { using (IWorkContextScope workContextScope = workContextAccessor.CreateWorkContextScope()) { ILifetimeScope lifetimeScope = workContextScope.Resolve <ILifetimeScope>(); registration = GetRegistration(lifetimeScope, constructorString); } } else { ILifetimeScope lifetimeScope = workContext.Resolve <ILifetimeScope>(); registration = GetRegistration(lifetimeScope, constructorString); } if (registration == null) { throw new InvalidOperationException(); } if (!registration.Activator.LimitType.IsClass) { throw new InvalidOperationException(); } return(CreateServiceHost(workContextAccessor, registration, registration.Activator.LimitType, baseAddresses)); }
private static void HostEndRequest(HttpApplication application, IBoyingHost host) { host.EndRequest(); }
private static void HostBeginRequest(HttpApplication application, IBoyingHost host) { application.Context.Items["originalHttpContext"] = application.Context; host.BeginRequest(); }