From 0518d32f517cc878c09b793342956277159b9013 Mon Sep 17 00:00:00 2001 From: Ian Johnson Date: Mon, 7 Jul 2014 14:40:15 -0600 Subject: [PATCH] Adding comments and using Named Parameters --- .../Grace/Modules/MvcSiteMapProviderModule.cs | 40 ++++++++++++++----- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/src/MvcSiteMapProvider/CodeAsConfiguration/Grace/DI/Grace/Modules/MvcSiteMapProviderModule.cs b/src/MvcSiteMapProvider/CodeAsConfiguration/Grace/DI/Grace/Modules/MvcSiteMapProviderModule.cs index 1ade18fc..93de75a3 100644 --- a/src/MvcSiteMapProvider/CodeAsConfiguration/Grace/DI/Grace/Modules/MvcSiteMapProviderModule.cs +++ b/src/MvcSiteMapProvider/CodeAsConfiguration/Grace/DI/Grace/Modules/MvcSiteMapProviderModule.cs @@ -90,29 +90,34 @@ public void Configure(IExportRegistrationBlock container) new Type[0], string.Empty); + // Visibility Providers container.Export() .As() - .WithCtorParam(() => string.Empty); + .WithCtorParam(() => string.Empty).Named("defaultProviderName"); + // Pass in the global controllerBuilder reference container.ExportInstance((s, c) => ControllerBuilder.Current); + container.Export().As(); + // Configure attribute security string attributeModuleKey = typeof(AuthorizeAttributeAclModule).Name; - container.Export() .As() .WithKey(attributeModuleKey); + // Configure XML security string xmlModuleKey = typeof(XmlRolesAclModule).Name; - container.Export() .As() .WithKey(xmlModuleKey); - + + // Combine attribute and xml security container.Export() .As() - .WithCtorParam().LocateWithKey(new[] { attributeModuleKey, xmlModuleKey }); + .WithCtorParam().Named("aclModules").LocateWithKey(new[] { attributeModuleKey, xmlModuleKey }); + // Configure cache container.ExportInstance( (scope, context) => System.Runtime.Caching.MemoryCache.Default); @@ -130,8 +135,10 @@ public void Configure(IExportRegistrationBlock container) .WithNamedCtorValue(() => absoluteCacheExpiration) .WithNamedCtorValue(() => slidingCacheExpiration); + // Configure the visitors container.Export().As(); + // Prepare for our node providers container.Export() .As() .WithKey("xmlSource1") @@ -140,7 +147,8 @@ public void Configure(IExportRegistrationBlock container) container.Export() .As(); - container.Export() + // Register the sitemap node providers + container.Export() .As() .WithKey("xmlSiteMapNodeProvider1") .WithCtorParam().LocateWithKey("xmlSource1") @@ -155,25 +163,35 @@ public void Configure(IExportRegistrationBlock container) container.Export() .As() + .WithKey("siteMapNodeProvider1") .WithCtorParam().LocateWithKey(new[] { "xmlSiteMapNodeProvider1", "reflectionSiteMapNodeProvider1" }); - container.Export().As(); + // Register the sitemap builders + container.Export() + .As() + .WithKey("siteMapBuilder1") + .WithCtorParam().Named("siteMapNodeProvider").LocateWithKey("siteMapNodeProvider1"); + // Configure the builder setsbuilderSet1 container.Export() .As() - .WithCtorParam(() => "default") - .WithCtorParam().LocateWithKey("cacheDetails1") + .WithKey("builderSet1") + .WithCtorParam(() => "default").Named("instanceName") + .WithCtorParam().Named("siteMapBuilder").LocateWithKey("siteMapBuilder1") + .WithCtorParam().Named("cacheDetails").LocateWithKey("cacheDetails1") .WithNamedCtorValue(() => securityTrimmingEnabled) .WithNamedCtorValue(() => enableLocalization) .WithNamedCtorValue(() => visibilityAffectsDescendants) .WithNamedCtorValue(() => useTitleIfDescriptionNotProvided); - container.Export().As(); - + // Configure the builder sets + container.Export() + .As() + .WithCtorParam().Named("siteMapBuilderSets").LocateWithKey(new[] { "builderSet1" }); } } }