示例#1
0
        public void Activate() {
            IAppBuilder appBuilder = new AppBuilder();
            appBuilder.Properties["host.AppName"] = _shellSettings.Name;

            var orderedMiddlewares = _owinMiddlewareProviders
                .SelectMany(p => p.GetOwinMiddlewares())
                .OrderBy(obj => obj.Priority, new FlatPositionComparer());

            foreach (var middleware in orderedMiddlewares) {
                middleware.Configure(appBuilder);
            }

            // register the Orchard middleware after all others
            appBuilder.UseOrchard();

            Func<IDictionary<string, object>, Task> pipeline = appBuilder.Build();

            var allRoutes = new List<RouteDescriptor>();
            allRoutes.AddRange(_routeProviders.SelectMany(provider => provider.GetRoutes()));
            allRoutes.AddRange(_httpRouteProviders.SelectMany(provider => provider.GetRoutes()));

            _routePublisher.Publish(allRoutes, pipeline);
            _modelBinderPublisher.Publish(_modelBinderProviders.SelectMany(provider => provider.GetModelBinders()));

            using (var scope = _workContextAccessor.CreateWorkContextScope()) {
                using (var events = scope.Resolve<Owned<IOrchardShellEvents>>()) {
                    events.Value.Activated();
                }
            }

            _sweepGenerator.Activate();
        }