// initialize a PublishedContentCache instance with
        // an XmlStore containing the master xml
        // an ICacheProvider that should be at request-level
        // a RoutesCache - need to cleanup that one
        // a preview token string (or null if not previewing)
        public PublishedContentCache(
            XmlStore xmlStore,            // an XmlStore containing the master xml
            IDomainCache domainCache,     // an IDomainCache implementation
            ICacheProvider cacheProvider, // an ICacheProvider that should be at request-level
            IGlobalSettings globalSettings,
            ISiteDomainHelper siteDomainHelper,
            PublishedContentTypeCache contentTypeCache, // a PublishedContentType cache
            RoutesCache routesCache,                    // a RoutesCache
            string previewToken)                        // a preview token string (or null if not previewing)
            : base(previewToken.IsNullOrWhiteSpace() == false)
        {
            _cacheProvider    = cacheProvider;
            _globalSettings   = globalSettings;
            _routesCache      = routesCache; // may be null for unit-testing
            _contentTypeCache = contentTypeCache;
            _domainCache      = domainCache;
            _domainHelper     = new DomainHelper(_domainCache, siteDomainHelper);

            _xmlStore = xmlStore;
            _xml      = _xmlStore.Xml; // capture - because the cache has to remain consistent

            if (previewToken.IsNullOrWhiteSpace() == false)
            {
                _previewContent = new PreviewContent(_xmlStore, previewToken);
            }
        }
        private PublishedSnapshotService(ServiceContext serviceContext,
                                         IPublishedContentTypeFactory publishedContentTypeFactory,
                                         IScopeProvider scopeProvider,
                                         ICacheProvider requestCache,
                                         IEnumerable <IUrlSegmentProvider> segmentProviders,
                                         IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor,
                                         IDocumentRepository documentRepository, IMediaRepository mediaRepository, IMemberRepository memberRepository,
                                         IDefaultCultureAccessor defaultCultureAccessor,
                                         ILogger logger,
                                         IGlobalSettings globalSettings,
                                         ISiteDomainHelper siteDomainHelper,
                                         PublishedContentTypeCache contentTypeCache,
                                         MainDom mainDom,
                                         bool testing, bool enableRepositoryEvents)
            : base(publishedSnapshotAccessor, variationContextAccessor)
        {
            _routesCache = new RoutesCache();
            _publishedContentTypeFactory = publishedContentTypeFactory;
            _contentTypeCache            = contentTypeCache
                                           ?? new PublishedContentTypeCache(serviceContext.ContentTypeService, serviceContext.MediaTypeService, serviceContext.MemberTypeService, publishedContentTypeFactory, logger);

            _xmlStore = new XmlStore(serviceContext, scopeProvider, _routesCache,
                                     _contentTypeCache, segmentProviders, publishedSnapshotAccessor, mainDom, testing, enableRepositoryEvents,
                                     documentRepository, mediaRepository, memberRepository, globalSettings);

            _domainService          = serviceContext.DomainService;
            _memberService          = serviceContext.MemberService;
            _mediaService           = serviceContext.MediaService;
            _userService            = serviceContext.UserService;
            _defaultCultureAccessor = defaultCultureAccessor;

            _requestCache     = requestCache;
            _globalSettings   = globalSettings;
            _siteDomainHelper = siteDomainHelper;
        }