Site Context

The SiteContext object contains information about the current request the site is executing, you can reference it at anytime like this PresentationTypeLoader.SiteContext. The Commerce Server Contrib project extends the CS SiteContext and adds some additional information like current user and basket information, you can access this extension by calling PresentationServiceLocator.Current.SiteContext.

If you need to centralize access to information about the site then site context is the place to do it. You can register your own SiteContext object by extending whatever type is registered in the SiteContext type in the web.config and then update the type reference to point to your new class. If you need to add any new properties or methods then you will also need to extended CommerceServerContrib.Web.ICommerceContext and then cast to your new interface where appropriate.

      <presentationConfiguration commerceConfigurationProviderType="CommerceServer.Foundation.DefaultConfigurationProvider, CommerceServer.Foundation.Presentation, Version=10.0.0.0, Culture=neutral, PublicKeyToken=f5c79cb11734af7a" cacheRefreshPollingTime="00:00:30">
        <default name="Default" channel="">
          <types>
            <type name="SiteContext" type="CommerceServerContrib.Web.SiteContext, CommerceServerContrib.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f5c79cb11734af7a" />
            <type name="ServiceAdapter" type="CommerceServer.Foundation.RequestTemplates.RequestTemplateServiceAdapter, CommerceServer.Foundation.Presentation, Version=10.0.0.0, Culture=neutral, PublicKeyToken=f5c79cb11734af7a" />
            <type name="ServiceAgent" type="CommerceServer.Foundation.RequestTemplates.MessageBundlingOperationServiceAgent, CommerceServer.Foundation.Presentation, Version=10.0.0.0, Culture=neutral, PublicKeyToken=f5c79cb11734af7a" />
          </types>

Last edited Dec 12, 2012 at 2:28 PM by cmcauliffe, version 5

Comments

No comments yet.