[4476] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Text;
|
---|
| 4 | using Microsoft.Practices.CompositeWeb;
|
---|
| 5 | using Microsoft.Practices.CompositeWeb.Interfaces;
|
---|
| 6 | using Microsoft.Practices.CompositeWeb.Services;
|
---|
| 7 | using Microsoft.Practices.CompositeWeb.Configuration;
|
---|
| 8 | using Microsoft.Practices.CompositeWeb.EnterpriseLibrary.Services;
|
---|
| 9 |
|
---|
| 10 | namespace 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 | }
|
---|