Skip to content

Commit

Permalink
Created SiteMapBuilderFactory to assist with DI containers that do no…
Browse files Browse the repository at this point in the history
…t have a way to resolve single parameters of constructors.
  • Loading branch information
NightOwl888 committed Sep 11, 2013
1 parent 08efd18 commit 74313f4
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using MvcSiteMapProvider.Caching;
using MvcSiteMapProvider.Visitor;

namespace MvcSiteMapProvider.Builder
{
public class SiteMapBuilderFactory
{
public SiteMapBuilderFactory(
ISiteMapNodeVisitor siteMapNodeVisitor,
ISiteMapHierarchyBuilder siteMapHierarchyBuilder,
ISiteMapCacheKeyGenerator siteMapCacheKeyGenerator,
ISiteMapNodeHelperFactory siteMapNodeHelperFactory
)
{
if (siteMapNodeVisitor == null)
throw new ArgumentNullException("siteMapNodeVisitor");
if (siteMapHierarchyBuilder == null)
throw new ArgumentNullException("siteMapHierarchyBuilder");
if (siteMapCacheKeyGenerator == null)
throw new ArgumentNullException("siteMapCacheKeyGenerator");
if (siteMapNodeHelperFactory == null)
throw new ArgumentNullException("siteMapNodeHelperFactory");

this.siteMapHierarchyBuilder = siteMapHierarchyBuilder;
this.siteMapCacheKeyGenerator = siteMapCacheKeyGenerator;
this.siteMapNodeHelperFactory = siteMapNodeHelperFactory;
this.siteMapNodeVisitor = siteMapNodeVisitor;
}
protected readonly ISiteMapHierarchyBuilder siteMapHierarchyBuilder;
protected readonly ISiteMapCacheKeyGenerator siteMapCacheKeyGenerator;
protected readonly ISiteMapNodeHelperFactory siteMapNodeHelperFactory;
protected readonly ISiteMapNodeVisitor siteMapNodeVisitor;

public virtual ISiteMapBuilder Create(ISiteMapNodeProvider siteMapNodeProvider)
{
return new SiteMapBuilder(
siteMapNodeProvider,
this.siteMapNodeVisitor,
this.siteMapHierarchyBuilder,
this.siteMapCacheKeyGenerator,
this.siteMapNodeHelperFactory);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
<Compile Include="Builder\ReflectionSiteMapNodeProvider.cs" />
<Compile Include="Builder\ReflectionSiteMapNodeProviderFactory.cs" />
<Compile Include="Builder\SiteMapBuilder.cs" />
<Compile Include="Builder\SiteMapBuilderFactory.cs" />
<Compile Include="Builder\SiteMapHierarchyBuilder.cs" />
<Compile Include="Builder\ISiteMapNodeCreatorFactory.cs" />
<Compile Include="Builder\SiteMapNodeCreatorFactory.cs" />
Expand Down

0 comments on commit 74313f4

Please sign in to comment.