diff --git a/src/MvcSiteMapProvider/CodeAsConfiguration/Autofac/DI/Autofac/Modules/MvcSiteMapProviderModule.cs b/src/MvcSiteMapProvider/CodeAsConfiguration/Autofac/DI/Autofac/Modules/MvcSiteMapProviderModule.cs index c5d14f82..78ed8eb5 100644 --- a/src/MvcSiteMapProvider/CodeAsConfiguration/Autofac/DI/Autofac/Modules/MvcSiteMapProviderModule.cs +++ b/src/MvcSiteMapProvider/CodeAsConfiguration/Autofac/DI/Autofac/Modules/MvcSiteMapProviderModule.cs @@ -135,7 +135,7 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType() .As(); - // Prepare for our builders + // Prepare for our node providers builder.RegisterType() .Named("xmlSource1") .WithParameter("fileName", absoluteFileName); @@ -144,32 +144,38 @@ protected override void Load(ContainerBuilder builder) .As() .WithParameter("attributesToIgnore", new string[0]); - // Register the sitemap builders - builder.RegisterType() - .Named("xmlSiteMapBuilder1") + + // Register the sitemap node providers + builder.RegisterType() + .Named("xmlSiteMapNodeProvider1") + .WithParameter("includeRootNode", true) + .WithParameter("useNestedDynamicNodeRecursion", false) .WithParameter( (p, c) => p.Name == "xmlSource", (p, c) => c.ResolveNamed("xmlSource1")); - builder.RegisterType() - .Named("reflectionSiteMapBuilder1") + builder.RegisterType() + .Named("reflectionSiteMapNodeProvider1") .WithParameter("includeAssemblies", includeAssembliesForScan) .WithParameter("excludeAssemblies", new string[0]); - builder.RegisterType() - .Named("visitingSiteMapBuilder1"); - - builder.RegisterType() - .Named("siteMapBuilder1") + builder.RegisterType() + .Named("siteMapNodeProvider1") .WithParameter( - (p, c) => p.Name == "siteMapBuilders", + (p, c) => p.Name == "siteMapNodeProviders", (p, c) => new[] { - c.ResolveNamed("xmlSiteMapBuilder1"), - c.ResolveNamed("reflectionSiteMapBuilder1"), - c.ResolveNamed("visitingSiteMapBuilder1") + c.ResolveNamed("xmlSiteMapNodeProvider1"), + c.ResolveNamed("reflectionSiteMapNodeProvider1") }); + // Register the sitemap builders + builder.RegisterType() + .Named("siteMapBuilder1") + .WithParameter( + (p, c) => p.Name == "siteMapNodeProvider", + (p, c) => c.ResolveNamed("siteMapNodeProvider1")); + // Configure the builder sets builder.RegisterType() .Named("builderSet1") diff --git a/src/MvcSiteMapProvider/CodeAsConfiguration/Ninject/DI/Ninject/Modules/MvcSiteMapProviderModule.cs b/src/MvcSiteMapProvider/CodeAsConfiguration/Ninject/DI/Ninject/Modules/MvcSiteMapProviderModule.cs index 7b04fd15..36686176 100644 --- a/src/MvcSiteMapProvider/CodeAsConfiguration/Ninject/DI/Ninject/Modules/MvcSiteMapProviderModule.cs +++ b/src/MvcSiteMapProvider/CodeAsConfiguration/Ninject/DI/Ninject/Modules/MvcSiteMapProviderModule.cs @@ -102,44 +102,39 @@ public override void Load() // Configure the visitors this.Kernel.Bind().To(); - // Register the sitemap builder - this.Kernel.Bind().To().Named("xmlBuilderXmlSource") + // Prepare for our node providers + this.Kernel.Bind().To().Named("XmlSource1") .WithConstructorArgument("fileName", absoluteFileName); this.Kernel.Bind().To().Named("xmlBuilderReservedAttributeNameProvider") .WithConstructorArgument("attributesToIgnore", new string[0]); - // Xml Builder - this.Kernel.Bind().To().Named("xmlSiteMapBuilder") - .WithConstructorArgument("reservedAttributeNameProvider", this.Kernel.Get("xmlBuilderReservedAttributeNameProvider")) - .WithConstructorArgument("xmlSource", this.Kernel.Get("xmlBuilderXmlSource")); + // Register the sitemap node providers + this.Kernel.Bind().To().Named("xmlSiteMapNodeProvider1") + .WithConstructorArgument("includeRootNode", true) + .WithConstructorArgument("useNestedDynamicNodeRecursion", false) + .WithConstructorArgument("xmlSource", this.Kernel.Get("XmlSource1")); - - - // Reflection Builder - this.Kernel.Bind().To().Named("reflectionSiteMapBuilder") + this.Kernel.Bind().To().Named("reflectionSiteMapNodeProvider1") .WithConstructorArgument("includeAssemblies", includeAssembliesForScan) .WithConstructorArgument("excludeAssemblies", new string[0]); - // Visiting Builder - this.Kernel.Bind().To().Named("visitingSiteMapBuilder"); - - - // Composite builder - this.Kernel.Bind().To().Named("compositeSiteMapBuilder") - .WithConstructorArgument("siteMapBuilders", - new ISiteMapBuilder[] { - this.Kernel.Get("xmlSiteMapBuilder"), - this.Kernel.Get("reflectionSiteMapBuilder"), - this.Kernel.Get("visitingSiteMapBuilder") + this.Kernel.Bind().To().Named("siteMapNodeProvider1") + .WithConstructorArgument("siteMapNodeProviders", + new ISiteMapNodeProvider[] { + this.Kernel.Get("xmlSiteMapNodeProvider1"), + this.Kernel.Get("reflectionSiteMapNodeProvider1") }); + // Register the sitemap builders + this.Kernel.Bind().To().Named("siteMapBuilder1") + .WithConstructorArgument("siteMapNodeProvider", this.Kernel.Get("siteMapNodeProvider1")); // Configure the builder sets this.Kernel.Bind().To().Named("siteMapBuilderSet1") .WithConstructorArgument("instanceName", "default") .WithConstructorArgument("securityTrimmingEnabled", securityTrimmingEnabled) .WithConstructorArgument("enableLocalization", enableLocalization) - .WithConstructorArgument("siteMapBuilder", this.Kernel.Get("compositeSiteMapBuilder")) + .WithConstructorArgument("siteMapBuilder", this.Kernel.Get("siteMapBuilder1")) .WithConstructorArgument("cacheDetails", this.Kernel.Get("cacheDetails1")); this.Kernel.Bind().To() diff --git a/src/MvcSiteMapProvider/CodeAsConfiguration/SimpleInjector/DI/SimpleInjector/MvcSiteMapProviderContainerInitializer.cs b/src/MvcSiteMapProvider/CodeAsConfiguration/SimpleInjector/DI/SimpleInjector/MvcSiteMapProviderContainerInitializer.cs index 0f72ab93..51aefc57 100644 --- a/src/MvcSiteMapProvider/CodeAsConfiguration/SimpleInjector/DI/SimpleInjector/MvcSiteMapProviderContainerInitializer.cs +++ b/src/MvcSiteMapProvider/CodeAsConfiguration/SimpleInjector/DI/SimpleInjector/MvcSiteMapProviderContainerInitializer.cs @@ -127,39 +127,25 @@ public static void SetUp(Container container) container.RegisterSingle(); - // Register the sitemap builder + // Prepare for the sitemap node providers container.RegisterSingle( () => new SiteMapXmlReservedAttributeNameProvider(new string[0])); container.RegisterSingle(() => new FileXmlSource(absoluteFileName)); - container.RegisterSingle(() => - new XmlSiteMapBuilder( - container.GetInstance(), - container.GetInstance(), - container.GetInstance(), - container.GetInstance(), - container.GetInstance(), - container.GetInstance() - )); - - container.RegisterSingle(() => - new ReflectionSiteMapBuilder( - includeAssembliesForScan, - new string[0], - container.GetInstance - (), - container.GetInstance(), - container.GetInstance(), - container.GetInstance(), - container.GetInstance() - )); + // Register the sitemap node providers + container.RegisterSingle(() => container.GetInstance() + .Create(container.GetInstance())); + container.RegisterSingle(() => container.GetInstance() + .Create(includeAssembliesForScan)); + + // Register the sitemap builders + container.RegisterSingle(() => container.GetInstance() + .Create(new CompositeSiteMapNodeProvider(container.GetInstance(), container.GetInstance()))); container.RegisterAll(ResolveISiteMapBuilderSets(container, securityTrimmingEnabled, enableLocalization)); container.RegisterSingle(() => new SiteMapBuilderSetStrategy(container.GetAllInstances().ToArray())); - - container.RegisterSingle(); } private static IEnumerable ResolveISiteMapBuilderSets(Container container, bool securityTrimmingEnabled, bool enableLocalization) @@ -168,10 +154,7 @@ private static IEnumerable ResolveISiteMapBuilderSets(Contai "default", securityTrimmingEnabled, enableLocalization, - new CompositeSiteMapBuilder( - container.GetInstance(), - container.GetInstance(), - container.GetInstance()), + container.GetInstance(), container.GetInstance()); } diff --git a/src/MvcSiteMapProvider/CodeAsConfiguration/StructureMap/DI/StructureMap/Registries/MvcSiteMapProviderRegistry.cs b/src/MvcSiteMapProvider/CodeAsConfiguration/StructureMap/DI/StructureMap/Registries/MvcSiteMapProviderRegistry.cs index 53064d13..27126218 100644 --- a/src/MvcSiteMapProvider/CodeAsConfiguration/StructureMap/DI/StructureMap/Registries/MvcSiteMapProviderRegistry.cs +++ b/src/MvcSiteMapProvider/CodeAsConfiguration/StructureMap/DI/StructureMap/Registries/MvcSiteMapProviderRegistry.cs @@ -124,26 +124,29 @@ public MvcSiteMapProviderRegistry() .Use(); - // Register the sitemap builder + // Prepare for our node providers var xmlSource = this.For().Use() .Ctor("fileName").Is(absoluteFileName); - var reservedAttributeNameProvider = this.For() - .Use() + this.For().Use() .Ctor>("attributesToIgnore").Is(new string[0]); - - var builder = this.For().Use() - .EnumerableOf().Contains(y => + + // Register the sitemap node providers + var siteMapNodeProvider = this.For().Use() + .EnumerableOf().Contains(x => { - y.Type() - .Ctor().Is(reservedAttributeNameProvider) + x.Type() + .Ctor("includeRootNode").Is(true) + .Ctor("useNestedDynamicNodeRecursion").Is(false) .Ctor().Is(xmlSource); - y.Type() + x.Type() .Ctor>("includeAssemblies").Is(includeAssembliesForScan) .Ctor>("excludeAssemblies").Is(new string[0]); - y.Type(); }); + // Register the sitemap builders + var builder = this.For().Use() + .Ctor().Is(siteMapNodeProvider); // Configure the builder sets this.For().Use() diff --git a/src/MvcSiteMapProvider/CodeAsConfiguration/Unity/DI/Unity/ContainerExtensions/MvcSiteMapProviderContainerExtension.cs b/src/MvcSiteMapProvider/CodeAsConfiguration/Unity/DI/Unity/ContainerExtensions/MvcSiteMapProviderContainerExtension.cs index 6b09e5ec..862560a4 100644 --- a/src/MvcSiteMapProvider/CodeAsConfiguration/Unity/DI/Unity/ContainerExtensions/MvcSiteMapProviderContainerExtension.cs +++ b/src/MvcSiteMapProvider/CodeAsConfiguration/Unity/DI/Unity/ContainerExtensions/MvcSiteMapProviderContainerExtension.cs @@ -121,22 +121,24 @@ protected override void Initialize() // Configure the visitors this.Container.RegisterType(); - // Register the sitemap builders + // Prepare for the sitemap node providers this.Container.RegisterType("file1XmlSource", new InjectionConstructor(absoluteFileName)); - this.Container.RegisterType("nameProvider", new InjectionConstructor(new List())); - + this.Container.RegisterType(new InjectionConstructor(new List())); // IMPORTANT: Must give arrays of object a name in Unity in order for it to resolve them. - this.Container.RegisterType("xmlSiteMapBuilder", new InjectionConstructor(new ResolvedParameter("file1XmlSource"), new ResolvedParameter("nameProvider"), typeof(INodeKeyGenerator), typeof(IDynamicNodeBuilder), typeof(ISiteMapNodeFactory), typeof(ISiteMapXmlNameProvider))); - this.Container.RegisterType("reflectionSiteMapBuilder", new InjectionConstructor(includeAssembliesForScan, new List(), new ResolvedParameter("nameProvider"), typeof(INodeKeyGenerator), typeof(IDynamicNodeBuilder), typeof(ISiteMapNodeFactory), typeof(ISiteMapCacheKeyGenerator))); - this.Container.RegisterType("visitingSiteMapBuilder"); - this.Container.RegisterType(new InjectionConstructor(new ResolvedArrayParameter( - new ResolvedParameter("xmlSiteMapBuilder"), - new ResolvedParameter("reflectionSiteMapBuilder"), - new ResolvedParameter("visitingSiteMapBuilder")))); + // Register the sitemap node providers + this.Container.RegisterInstance("xmlSiteMapNodeProvider1", + this.Container.Resolve().Create(this.Container.Resolve("file1XmlSource")), new ContainerControlledLifetimeManager()); + this.Container.RegisterInstance("ReflectionSiteMapNodeProvider1", + this.Container.Resolve().Create(includeAssembliesForScan), new ContainerControlledLifetimeManager()); + this.Container.RegisterType(new InjectionConstructor(new ResolvedArrayParameter( + new ResolvedParameter("xmlSiteMapNodeProvider1"), + new ResolvedParameter("ReflectionSiteMapNodeProvider1")))); + + // Configure the builders + this.Container.RegisterType(); // Configure the builder sets - this.Container.RegisterType("builderSet1", new InjectionConstructor( "default", diff --git a/src/MvcSiteMapProvider/CodeAsConfiguration/Windsor/DI/Windsor/Installers/MvcSiteMapProviderInstaller.cs b/src/MvcSiteMapProvider/CodeAsConfiguration/Windsor/DI/Windsor/Installers/MvcSiteMapProviderInstaller.cs index e6c214cb..a6ce2192 100644 --- a/src/MvcSiteMapProvider/CodeAsConfiguration/Windsor/DI/Windsor/Installers/MvcSiteMapProviderInstaller.cs +++ b/src/MvcSiteMapProvider/CodeAsConfiguration/Windsor/DI/Windsor/Installers/MvcSiteMapProviderInstaller.cs @@ -119,27 +119,32 @@ public void Install(IWindsorContainer container, IConfigurationStore store) // Configure the visitors container.Register(Component.For().ImplementedBy()); - // Register the sitemap builder + // Prepare for the sitemap node providers container.Register(Component.For().ImplementedBy().Named("xmlSource1") .DependsOn(Dependency.OnValue("fileName", absoluteFileName))); container.Register(Component.For().ImplementedBy() .DependsOn(Dependency.OnValue("attributesToIgnore", new string[0]))); - container.Register(Component.For().ImplementedBy().Named("builder1") - .DependsOn(Dependency.OnComponentCollection("xmlSiteMapBuilder1", "reflectionSiteMapBuilder1", "visitingSiteMapBuilder1"))); + // Register the sitemap node providers + container.Register(Component.For().ImplementedBy().Named("siteMapNodeProvider1") + .DependsOn(Dependency.OnComponentCollection("xmlSiteMapNodeProvider1", "reflectionSiteMapNodeProvider1"))); - container.Register(Component.For().ImplementedBy().Named("xmlSiteMapBuilder1") - .DependsOn(Dependency.OnValue(container.Resolve())) + container.Register(Component.For().ImplementedBy().Named("xmlSiteMapNodeProvider1") + .DependsOn(Dependency.OnValue("includeRootNode", true)) + .DependsOn(Dependency.OnValue("useNestedDynamicNodeRecursion", false)) .DependsOn(ServiceOverride.ForKey().Eq("xmlSource1")) ); - container.Register(Component.For().ImplementedBy().Named("reflectionSiteMapBuilder1") + container.Register(Component.For().ImplementedBy().Named("reflectionSiteMapNodeProvider1") .DependsOn(Dependency.OnValue("includeAssemblies", includeAssembliesForScan)) .DependsOn(Dependency.OnValue("excludeAssemblies", new string[0])) ); - container.Register(Component.For().ImplementedBy().Named("visitingSiteMapBuilder1")); - + // Register the sitemap builders + container.Register(Component.For().ImplementedBy().Named("builder1") + .DependsOn(ServiceOverride.ForKey().Eq("siteMapNodeProvider1")) + ); + // Configure the builder sets container.Register(Component.For().ImplementedBy().Named("siteMapBuilderSet1") .DependsOn(Dependency.OnValue("instanceName", "default"))