Free cookie consent management tool by TermsFeed Policy Generator

source: branches/WebApplication/Administration/AdministrationModuleInitializer.cs @ 4930

Last change on this file since 4930 was 4476, checked in by cfleisch, 14 years ago

Create repository (#1198)

File size: 2.6 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Text;
4using Microsoft.Practices.CompositeWeb;
5using Microsoft.Practices.CompositeWeb.Interfaces;
6using Microsoft.Practices.CompositeWeb.Services;
7using Microsoft.Practices.CompositeWeb.Configuration;
8using Microsoft.Practices.CompositeWeb.EnterpriseLibrary.Services;
9
10namespace OKB.Administration
11{
12    public class AdministrationModuleInitializer : ModuleInitializer
13    {
14        private const string AuthorizationSection = "compositeWeb/authorization";
15
16        public override void Load(CompositionContainer container)
17        {
18            base.Load(container);
19
20            AddGlobalServices(container.Parent.Services);
21            AddModuleServices(container.Services);
22            RegisterSiteMapInformation(container.Services.Get<ISiteMapBuilderService>(true));
23
24            container.RegisterTypeMapping<IAdministrationController, AdministrationController>();
25        }
26
27        protected virtual void AddGlobalServices(IServiceCollection globalServices)
28        {
29            // TODO: add a service that will be visible to any module
30        }
31
32        protected virtual void AddModuleServices(IServiceCollection moduleServices)
33        {
34            // TODO: add a service that will be visible to this module
35        }
36
37        protected virtual void RegisterSiteMapInformation(ISiteMapBuilderService siteMapBuilderService)
38        {
39            SiteMapNodeInfo moduleNode = new SiteMapNodeInfo("Administration", "~/Administration/Default.aspx", "Administration");
40            siteMapBuilderService.AddNode(moduleNode);
41
42            // TODO: register other site map nodes that Administration module might provide           
43        }
44
45        public override void Configure(IServiceCollection services, System.Configuration.Configuration moduleConfiguration)
46        {
47            IAuthorizationRulesService authorizationRuleService = services.Get<IAuthorizationRulesService>();
48            if (authorizationRuleService != null)
49            {
50                AuthorizationConfigurationSection authorizationSection = moduleConfiguration.GetSection(AuthorizationSection) as AuthorizationConfigurationSection;
51                if (authorizationSection != null)
52                {
53                    foreach (AuthorizationRuleElement ruleElement in authorizationSection.ModuleRules)
54                    {
55                        authorizationRuleService.RegisterAuthorizationRule(ruleElement.AbsolutePath, ruleElement.RuleName);
56                    }
57                }
58            }
59        }
60    }
61}
Note: See TracBrowser for help on using the repository browser.