Dynamic Sites Manager 1.9.1 – Update


In true Sitecore fashion, I wanted to quickly get an initial working version of Dynamic Sites Manager out the door for the Sitecore 8.2 Initial Release.  Tonight, I went back into the code and realized that the SiteManager.Providers property has been marked obsolete, something that wasn’t very clear in the Release Notes. This means at some point in a later release, SiteManager.Providers will become a breaking change.

As such, I wanted to go ahead and clean that up.  Instead of using this property, I am now calling the service using dependency injection. Originally, I wasn’t using a constructor for my SwitcherSiteProvider class, but now I am.

 private readonly ProviderHelper<SiteProvider, SiteProviderCollection> _providerHelper;

public SwitcherSiteProvider(ProviderHelper<SiteProvider, SiteProviderCollection> providerHelper)
_providerHelper = providerHelper;

However, there’s one more step that I have to take.  I have to tell Sitecore’s Configuration Factory that it needs to resolve this class for dependency.

      <patch:attribute name="defaultProvider">switcher</patch:attribute>
        <add name="dynamic" type="Sitecore.SharedSource.DynamicSites.Sites.DynamicSitesProvider, SharedSource.Sitecore.DynamicSites" siteConfig="dynamicsites" checkSecurity="false" />
        <add name="switcher" type="Sitecore.SharedSource.DynamicSites.Sites.SwitcherSiteProvider, SharedSource.Sitecore.DynamicSites" checkSecurity="false" resolve="true" />

The magic is in the addition of the resolve=”true” attribute on my provider.

Time to use the hell out of the built in dependency injection with Sitecore 8.2!

Get Dynamic Sites Now

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s