Beispiel #1
0
        public ContentStore(
            IPublishedSnapshotAccessor publishedSnapshotAccessor,
            IVariationContextAccessor variationContextAccessor,
            IUmbracoContextAccessor umbracoContextAccessor,
            ILogger logger,
            BPlusTree <int, ContentNodeKit> localDb = null)
        {
            _publishedSnapshotAccessor = publishedSnapshotAccessor;
            _variationContextAccessor  = variationContextAccessor;
            _umbracoContextAccessor    = umbracoContextAccessor;
            _logger  = logger;
            _localDb = localDb;

            _contentNodes        = new ConcurrentDictionary <int, LinkedNode <ContentNode> >();
            _contentRootNodes    = new ConcurrentDictionary <int, LinkedNode <object> >();
            _contentTypesById    = new ConcurrentDictionary <int, LinkedNode <PublishedContentType> >();
            _contentTypesByAlias = new ConcurrentDictionary <string, LinkedNode <PublishedContentType> >(StringComparer.InvariantCultureIgnoreCase);
            _xmap = new ConcurrentDictionary <Guid, int>();

            _genObjs     = new ConcurrentQueue <GenObj>();
            _genObj      = null;  // no initial gen exists
            _liveGen     = _floorGen = 0;
            _nextGen     = false; // first time, must create a snapshot
            _collectAuto = true;  // collect automatically by default
        }
        public static IPublishedContent Create(
            IMember member,
            PublishedContentType contentType,
            bool previewing,
            IPublishedSnapshotAccessor publishedSnapshotAccessor,
            IVariationContextAccessor variationContextAccessor,
            IUmbracoContextAccessor umbracoContextAccessor)
        {
            var d = new ContentData
            {
                Name        = member.Name,
                Published   = previewing,
                TemplateId  = -1,
                VersionDate = member.UpdateDate,
                WriterId    = member.CreatorId, // what else?
                Properties  = GetPropertyValues(contentType, member)
            };
            var n = new ContentNode(member.Id, member.Key,
                                    contentType,
                                    member.Level, member.Path, member.SortOrder,
                                    member.ParentId,
                                    member.CreateDate, member.CreatorId);

            return(new PublishedMember(member, n, d, publishedSnapshotAccessor, variationContextAccessor, umbracoContextAccessor).CreateModel());
        }
        // initialize a PublishedContentCache instance with
        // an XmlStore containing the master xml
        // an IAppCache 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
            IAppCache appCache,                         // an IAppCache that should be at request-level
            GlobalSettings globalSettings,
            PublishedContentTypeCache contentTypeCache, // a PublishedContentType cache
            RoutesCache routesCache,                    // a RoutesCache
            IVariationContextAccessor variationContextAccessor,
            string previewToken)                        // a preview token string (or null if not previewing)
            : base(previewToken.IsNullOrWhiteSpace() == false)
        {
            _appCache                 = appCache;
            _globalSettings           = globalSettings;
            _routesCache              = routesCache; // may be null for unit-testing
            _variationContextAccessor = variationContextAccessor;
            _contentTypeCache         = contentTypeCache;
            _domainCache              = domainCache;

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

            if (previewToken.IsNullOrWhiteSpace() == false)
            {
                _previewContent = new PreviewContent(_xmlStore, previewToken);
            }
        }
 public SiteMapService(IUmbracoContextFactory contextFactory, IVariationContextAccessor variationContextAccessor, ILocalizationService localizationService, IDomainService domainService)
 {
     _contextFactory         = contextFactory;
     _variantContextAccessor = variationContextAccessor;
     _localizationService    = localizationService;
     _domainService          = domainService;
 }
Beispiel #5
0
        // initializes a new instance of the UmbracoContext class
        // internal for unit tests
        // otherwise it's used by EnsureContext above
        // warn: does *not* manage setting any IUmbracoContextAccessor
        internal UmbracoContext(HttpContextBase httpContext,
                                IPublishedSnapshotService publishedSnapshotService,
                                WebSecurity webSecurity,
                                IUmbracoSettingsSection umbracoSettings,
                                IEnumerable <IUrlProvider> urlProviders,
                                IGlobalSettings globalSettings,
                                IVariationContextAccessor variationContextAccessor)
        {
            if (httpContext == null)
            {
                throw new ArgumentNullException(nameof(httpContext));
            }
            if (publishedSnapshotService == null)
            {
                throw new ArgumentNullException(nameof(publishedSnapshotService));
            }
            if (webSecurity == null)
            {
                throw new ArgumentNullException(nameof(webSecurity));
            }
            if (umbracoSettings == null)
            {
                throw new ArgumentNullException(nameof(umbracoSettings));
            }
            if (urlProviders == null)
            {
                throw new ArgumentNullException(nameof(urlProviders));
            }
            VariationContextAccessor = variationContextAccessor ?? throw new ArgumentNullException(nameof(variationContextAccessor));
            _globalSettings          = globalSettings ?? throw new ArgumentNullException(nameof(globalSettings));

            // ensure that this instance is disposed when the request terminates, though we *also* ensure
            // this happens in the Umbraco module since the UmbracoCOntext is added to the HttpContext items.
            //
            // also, it *can* be returned by the container with a PerRequest lifetime, meaning that the
            // container *could* also try to dispose it.
            //
            // all in all, this context may be disposed more than once, but DisposableObject ensures that
            // it is ok and it will be actually disposed only once.
            httpContext.DisposeOnPipelineCompleted(this);

            ObjectCreated    = DateTime.Now;
            UmbracoRequestId = Guid.NewGuid();
            HttpContext      = httpContext;
            Security         = webSecurity;

            // beware - we cannot expect a current user here, so detecting preview mode must be a lazy thing
            _publishedSnapshot = new Lazy <IPublishedSnapshot>(() => publishedSnapshotService.CreatePublishedSnapshot(PreviewToken));

            // set the urls...
            // NOTE: The request will not be available during app startup so we can only set this to an absolute URL of localhost, this
            // is a work around to being able to access the UmbracoContext during application startup and this will also ensure that people
            // 'could' still generate URLs during startup BUT any domain driven URL generation will not work because it is NOT possible to get
            // the current domain during application startup.
            // see: http://issues.umbraco.org/issue/U4-1890
            //
            OriginalRequestUrl = GetRequestFromContext()?.Url ?? new Uri("http://localhost");
            CleanedUmbracoUrl  = UriUtility.UriToUmbraco(OriginalRequestUrl);
            UrlProvider        = new UrlProvider(this, umbracoSettings.WebRouting, urlProviders, variationContextAccessor);
        }
 // used in WebBootManager + tests
 public XmlPublishedSnapshotService(
     ServiceContext serviceContext,
     IPublishedContentTypeFactory publishedContentTypeFactory,
     IScopeProvider scopeProvider,
     IAppCache requestCache,
     IPublishedSnapshotAccessor publishedSnapshotAccessor,
     IVariationContextAccessor variationContextAccessor,
     IUmbracoContextAccessor umbracoContextAccessor,
     IDocumentRepository documentRepository,
     IMediaRepository mediaRepository,
     IMemberRepository memberRepository,
     IDefaultCultureAccessor defaultCultureAccessor,
     ILoggerFactory loggerFactory,
     GlobalSettings globalSettings,
     IHostingEnvironment hostingEnvironment,
     IApplicationShutdownRegistry hostingLifetime,
     IShortStringHelper shortStringHelper,
     IEntityXmlSerializer entitySerializer,
     MainDom mainDom,
     bool testing = false,
     bool enableRepositoryEvents = true)
     : this(serviceContext, publishedContentTypeFactory, scopeProvider, requestCache,
            publishedSnapshotAccessor, variationContextAccessor, umbracoContextAccessor,
            documentRepository, mediaRepository, memberRepository,
            defaultCultureAccessor,
            loggerFactory, globalSettings, hostingEnvironment, hostingLifetime, shortStringHelper, entitySerializer, null, mainDom, testing, enableRepositoryEvents)
 {
     _umbracoContextAccessor = umbracoContextAccessor;
 }
        public UmbracoInjectedModule(
            IGlobalSettings globalSettings,
            IUmbracoContextAccessor umbracoContextAccessor,
            IPublishedSnapshotService publishedSnapshotService,
            IUserService userService,
            UrlProviderCollection urlProviders,
            IRuntimeState runtime,
            ILogger logger,
            IPublishedRouter publishedRouter,
            IVariationContextAccessor variationContextAccessor,
            IUmbracoContextFactory umbracoContextFactory)
        {
            _combinedRouteCollection = new Lazy <RouteCollection>(CreateRouteCollection);

            _globalSettings           = globalSettings;
            _umbracoContextAccessor   = umbracoContextAccessor;
            _publishedSnapshotService = publishedSnapshotService;
            _userService              = userService;
            _urlProviders             = urlProviders;
            _runtime                  = runtime;
            _logger                   = logger;
            _publishedRouter          = publishedRouter;
            _variationContextAccessor = variationContextAccessor;
            _umbracoContextFactory    = umbracoContextFactory;
        }
    private static async Task <Attempt <UrlInfo?> > DetectCollisionAsync(
        ILogger logger,
        IContent content,
        string url,
        string culture,
        IUmbracoContext umbracoContext,
        IPublishedRouter publishedRouter,
        ILocalizedTextService textService,
        IVariationContextAccessor variationContextAccessor,
        UriUtility uriUtility)
    {
        // test for collisions on the 'main' URL
        var uri = new Uri(url.TrimEnd(Constants.CharArrays.ForwardSlash), UriKind.RelativeOrAbsolute);

        if (uri.IsAbsoluteUri == false)
        {
            uri = uri.MakeAbsolute(umbracoContext.CleanedUmbracoUrl);
        }

        uri = uriUtility.UriToUmbraco(uri);
        IPublishedRequestBuilder builder = await publishedRouter.CreateRequestAsync(uri);

        IPublishedRequest pcr =
            await publishedRouter.RouteRequestAsync(builder, new RouteRequestOptions(RouteDirection.Outbound));

        if (!pcr.HasPublishedContent())
        {
            const string logMsg = nameof(DetectCollisionAsync) +
                                  " did not resolve a content item for original url: {Url}, translated to {TranslatedUrl} and culture: {Culture}";
            logger.LogDebug(logMsg, url, uri, culture);

            var urlInfo = UrlInfo.Message(textService.Localize("content", "routeErrorCannotRoute"), culture);
            return(Attempt.Succeed(urlInfo));
        }

        if (pcr.IgnorePublishedContentCollisions)
        {
            return(Attempt <UrlInfo?> .Fail());
        }

        if (pcr.PublishedContent?.Id != content.Id)
        {
            IPublishedContent?o = pcr.PublishedContent;
            var l = new List <string>();
            while (o != null)
            {
                l.Add(o.Name(variationContextAccessor) !);
                o = o.Parent;
            }

            l.Reverse();
            var s = "/" + string.Join("/", l) + " (id=" + pcr.PublishedContent?.Id + ")";

            var urlInfo = UrlInfo.Message(textService.Localize("content", "routeError", new[] { s }), culture);
            return(Attempt.Succeed(urlInfo));
        }

        // no collision
        return(Attempt <UrlInfo?> .Fail());
    }
Beispiel #9
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="PublishedRouter" /> class.
 /// </summary>
 public PublishedRouter(
     IOptionsMonitor <WebRoutingSettings> webRoutingSettings,
     ContentFinderCollection contentFinders,
     IContentLastChanceFinder contentLastChanceFinder,
     IVariationContextAccessor variationContextAccessor,
     IProfilingLogger proflog,
     ILogger <PublishedRouter> logger,
     IPublishedUrlProvider publishedUrlProvider,
     IRequestAccessor requestAccessor,
     IPublishedValueFallback publishedValueFallback,
     IFileService fileService,
     IContentTypeService contentTypeService,
     IUmbracoContextAccessor umbracoContextAccessor,
     IEventAggregator eventAggregator)
 {
     _webRoutingSettings = webRoutingSettings.CurrentValue ??
                           throw new ArgumentNullException(nameof(webRoutingSettings));
     _contentFinders          = contentFinders ?? throw new ArgumentNullException(nameof(contentFinders));
     _contentLastChanceFinder =
         contentLastChanceFinder ?? throw new ArgumentNullException(nameof(contentLastChanceFinder));
     _profilingLogger          = proflog ?? throw new ArgumentNullException(nameof(proflog));
     _variationContextAccessor = variationContextAccessor ??
                                 throw new ArgumentNullException(nameof(variationContextAccessor));
     _logger = logger;
     _publishedUrlProvider   = publishedUrlProvider;
     _requestAccessor        = requestAccessor;
     _publishedValueFallback = publishedValueFallback;
     _fileService            = fileService;
     _contentTypeService     = contentTypeService;
     _umbracoContextAccessor = umbracoContextAccessor;
     _eventAggregator        = eventAggregator;
     webRoutingSettings.OnChange(x => _webRoutingSettings = x);
 }
Beispiel #10
0
        public PublishedMember(
            IMember member,
            IPublishedContentType publishedMemberType,
            IVariationContextAccessor variationContextAccessor) : base(variationContextAccessor)
        {
            _member              = member ?? throw new ArgumentNullException(nameof(member));
            _membershipUser      = member;
            _publishedMemberType = publishedMemberType ?? throw new ArgumentNullException(nameof(publishedMemberType));

            // RawValueProperty is used for two things here
            // - for the 'map properties' thing that we should really get rid of
            // - for populating properties that every member should always have, and that we force-create
            //   if they are not part of the member type properties - in which case they are created as
            //   simple raw properties - which are completely invariant

            var properties = new List <IPublishedProperty>();

            foreach (var propertyType in _publishedMemberType.PropertyTypes)
            {
                var property = _member.Properties[propertyType.Alias];
                if (property == null)
                {
                    continue;
                }

                properties.Add(new RawValueProperty(propertyType, this, property.GetValue()));
            }
            EnsureMemberProperties(properties);
            _properties = properties.ToArray();
        }
Beispiel #11
0
        public PublishedContent(
            ContentNode contentNode,
            ContentData contentData,
            IPublishedSnapshotAccessor publishedSnapshotAccessor,
            IVariationContextAccessor variationContextAccessor)
        {
            _contentNode = contentNode ?? throw new ArgumentNullException(nameof(contentNode));
            ContentData  = contentData ?? throw new ArgumentNullException(nameof(contentData));
            _publishedSnapshotAccessor = publishedSnapshotAccessor ?? throw new ArgumentNullException(nameof(publishedSnapshotAccessor));
            VariationContextAccessor   = variationContextAccessor ?? throw new ArgumentNullException(nameof(variationContextAccessor));

            _urlSegment  = ContentData.UrlSegment;
            IsPreviewing = ContentData.Published == false;

            var properties = new IPublishedProperty[_contentNode.ContentType.PropertyTypes.Count()];
            int i          = 0;

            foreach (var propertyType in _contentNode.ContentType.PropertyTypes)
            {
                // add one property per property type - this is required, for the indexing to work
                // if contentData supplies pdatas, use them, else use null
                contentData.Properties.TryGetValue(propertyType.Alias, out var pdatas); // else will be null
                properties[i++] = new Property(propertyType, this, pdatas, _publishedSnapshotAccessor);
            }
            PropertiesArray = properties;
        }
Beispiel #12
0
 public static void ContextualizeVariation(
     this IVariationContextAccessor variationContextAccessor,
     ContentVariation variations,
     int contentId,
     ref string?culture,
     ref string?segment)
 => variationContextAccessor.ContextualizeVariation(variations, (int?)contentId, ref culture, ref segment);
Beispiel #13
0
    private static void ContextualizeVariation(
        this IVariationContextAccessor variationContextAccessor,
        ContentVariation variations,
        int?contentId,
        ref string?culture,
        ref string?segment)
    {
        if (culture != null && segment != null)
        {
            return;
        }

        // use context values
        VariationContext?publishedVariationContext = variationContextAccessor?.VariationContext;

        if (culture == null)
        {
            culture = variations.VariesByCulture() ? publishedVariationContext?.Culture : string.Empty;
        }

        if (segment == null)
        {
            if (variations.VariesBySegment())
            {
                segment = contentId == null
                    ? publishedVariationContext?.Segment
                    : publishedVariationContext?.GetSegment(contentId.Value);
            }
            else
            {
                segment = string.Empty;
            }
        }
    }
 public UmbracoRequestMiddleware(
     ILogger <UmbracoRequestMiddleware> logger,
     IUmbracoContextFactory umbracoContextFactory,
     IRequestCache requestCache,
     IEventAggregator eventAggregator,
     IProfiler profiler,
     IHostingEnvironment hostingEnvironment,
     UmbracoRequestPaths umbracoRequestPaths,
     BackOfficeWebAssets backOfficeWebAssets,
     IOptionsMonitor <SmidgeOptions> smidgeOptions,
     IRuntimeState runtimeState,
     IVariationContextAccessor variationContextAccessor,
     IDefaultCultureAccessor defaultCultureAccessor)
     : this(
         logger,
         umbracoContextFactory,
         requestCache,
         eventAggregator,
         profiler,
         hostingEnvironment,
         umbracoRequestPaths,
         backOfficeWebAssets,
         smidgeOptions,
         runtimeState,
         variationContextAccessor,
         defaultCultureAccessor,
         StaticServiceProvider.Instance.GetRequiredService <IOptions <UmbracoRequestOptions> >())
 {
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="UmbracoRequestMiddleware"/> class.
        /// </summary>
        public UmbracoRequestMiddleware(
            ILogger <UmbracoRequestMiddleware> logger,
            IUmbracoContextFactory umbracoContextFactory,
            IRequestCache requestCache,
            IEventAggregator eventAggregator,
            IProfiler profiler,
            IHostingEnvironment hostingEnvironment,
            UmbracoRequestPaths umbracoRequestPaths,
            BackOfficeWebAssets backOfficeWebAssets,
            IOptionsMonitor <SmidgeOptions> smidgeOptions,
            IRuntimeState runtimeState,
            IVariationContextAccessor variationContextAccessor,
            IDefaultCultureAccessor defaultCultureAccessor,
            IOptions <UmbracoRequestOptions> umbracoRequestOptions)
        {
            _logger = logger;
            _umbracoContextFactory    = umbracoContextFactory;
            _requestCache             = requestCache;
            _eventAggregator          = eventAggregator;
            _hostingEnvironment       = hostingEnvironment;
            _umbracoRequestPaths      = umbracoRequestPaths;
            _backOfficeWebAssets      = backOfficeWebAssets;
            _runtimeState             = runtimeState;
            _variationContextAccessor = variationContextAccessor;
            _defaultCultureAccessor   = defaultCultureAccessor;
            _umbracoRequestOptions    = umbracoRequestOptions;
            _smidgeOptions            = smidgeOptions.CurrentValue;
            _profiler = profiler as WebProfiler; // Ignore if not a WebProfiler

            smidgeOptions.OnChange(x => _smidgeOptions = x);
        }
Beispiel #16
0
            public PagePublishedContent(IContent inner, IVariationContextAccessor variationContextAccessor)
            {
                if (inner == null)
                {
                    throw new NullReferenceException("content");
                }

                _inner = inner;
                _variationContextAccessor = variationContextAccessor;
                _id  = _inner.Id;
                _key = _inner.Key;

                //TODO: ARGH! need to fix this - this is not good because it uses ApplicationContext.Current
                _creatorName = _inner.GetCreatorProfile().Name;
                _writerName  = _inner.GetWriterProfile().Name;

                _contentType = Current.PublishedContentTypeFactory.CreateContentType(_inner.ContentType);

                _properties = _contentType.PropertyTypes
                              .Select(x =>
                {
                    var p = _inner.Properties.SingleOrDefault(xx => xx.Alias == x.Alias);
                    return(p == null ? new PagePublishedProperty(x, this) : new PagePublishedProperty(x, this, p));
                })
                              .Cast <IPublishedProperty>()
                              .ToArray();

                _parent = new PagePublishedContent(_inner.ParentId);
            }
Beispiel #17
0
            public PagePublishedContent(IContent inner, IVariationContextAccessor variationContextAccessor)
            {
                _inner = inner ?? throw new NullReferenceException("content");
                _variationContextAccessor = variationContextAccessor;
                Id  = _inner.Id;
                Key = _inner.Key;

                CreatorName = _inner.GetCreatorProfile()?.Name;
                WriterName  = _inner.GetWriterProfile()?.Name;

                // TODO: inject
                var contentType = Current.Services.ContentTypeBaseServices.GetContentTypeOf(_inner);

                ContentType = Current.PublishedContentTypeFactory.CreateContentType(contentType);

                _properties = ContentType.PropertyTypes
                              .Select(x =>
                {
                    var p = _inner.Properties.SingleOrDefault(xx => xx.Alias == x.Alias);
                    return(p == null ? new PagePublishedProperty(x, this) : new PagePublishedProperty(x, this, p));
                })
                              .Cast <IPublishedProperty>()
                              .ToArray();

                Parent = new PagePublishedContent(_inner.ParentId);
            }
 public MacroRenderingController(IUmbracoComponentRenderer componentRenderer, IVariationContextAccessor variationContextAccessor, IMacroService macroService, IContentService contentService)
 {
     _componentRenderer        = componentRenderer;
     _variationContextAccessor = variationContextAccessor;
     _macroService             = macroService;
     _contentService           = contentService;
 }
    public async Task Lookup_By_Url_Alias(
        string relativeUrl,
        int nodeMatch,
        [Frozen] IPublishedContentCache publishedContentCache,
        [Frozen] IUmbracoContextAccessor umbracoContextAccessor,
        [Frozen] IUmbracoContext umbracoContext,
        [Frozen] IVariationContextAccessor variationContextAccessor,
        IFileService fileService,
        ContentFinderByUrlAlias sut,
        IPublishedContent[] rootContents,
        IPublishedProperty urlProperty)
    {
        // Arrange
        var absoluteUrl      = "http://localhost" + relativeUrl;
        var variationContext = new VariationContext();

        var contentItem = rootContents[0];

        Mock.Get(umbracoContextAccessor).Setup(x => x.TryGetUmbracoContext(out umbracoContext)).Returns(true);
        Mock.Get(umbracoContext).Setup(x => x.Content).Returns(publishedContentCache);
        Mock.Get(publishedContentCache).Setup(x => x.GetAtRoot(null)).Returns(rootContents);
        Mock.Get(contentItem).Setup(x => x.Id).Returns(nodeMatch);
        Mock.Get(contentItem).Setup(x => x.GetProperty(Constants.Conventions.Content.UrlAlias)).Returns(urlProperty);
        Mock.Get(urlProperty).Setup(x => x.GetValue(null, null)).Returns(relativeUrl);

        Mock.Get(variationContextAccessor).Setup(x => x.VariationContext).Returns(variationContext);
        var publishedRequestBuilder = new PublishedRequestBuilder(new Uri(absoluteUrl, UriKind.Absolute), fileService);

        // Act
        var result = await sut.TryFindContent(publishedRequestBuilder);

        Assert.IsTrue(result);
        Assert.AreEqual(publishedRequestBuilder.PublishedContent.Id, nodeMatch);
    }
 public CultureContextualSearchResultsEnumerator(IEnumerator <PublishedSearchResult> wrapped,
                                                 IVariationContextAccessor variationContextAccessor, VariationContext originalContext)
 {
     _wrapped = wrapped;
     _variationContextAccessor = variationContextAccessor;
     _originalContext          = originalContext;
 }
 public CultureContextualSearchResults(IEnumerable <PublishedSearchResult> wrapped,
                                       IVariationContextAccessor variationContextAccessor, string culture)
 {
     _wrapped = wrapped;
     _variationContextAccessor = variationContextAccessor;
     _culture = culture;
 }
 public BentoResourceController(IContentService contentService, IContentTypeService contentTypeService, IPagingHelper pagingHelper, IPluralizationServiceWrapper pluralizationServiceWrapper, IVariationContextAccessor variationContextAccessor)
 {
     _contentService              = contentService;
     _contentTypeService          = contentTypeService;
     _pagingHelper                = pagingHelper;
     _pluralizationServiceWrapper = pluralizationServiceWrapper;
     _variationContextAccessor    = variationContextAccessor;
 }
Beispiel #23
0
 private PublishedMember(
     IMember member,
     ContentNode contentNode,
     ContentData contentData,
     IPublishedSnapshotAccessor publishedSnapshotAccessor,
     IVariationContextAccessor variationContextAccessor,
     IPublishedModelFactory publishedModelFactory)
     : base(contentNode, contentData, publishedSnapshotAccessor, variationContextAccessor, publishedModelFactory) =>
Beispiel #24
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UrlProvider"/> class with an Umbraco context and a list of url providers.
        /// </summary>
        /// <param name="umbracoContext">The Umbraco context.</param>
        /// <param name="urlProviders">The list of url providers.</param>
        /// <param name="variationContextAccessor">The current variation accessor.</param>
        /// <param name="mode">An optional provider mode.</param>
        public UrlProvider(UmbracoContext umbracoContext, IEnumerable <IUrlProvider> urlProviders, IVariationContextAccessor variationContextAccessor, UrlProviderMode mode = UrlProviderMode.Auto)
        {
            _umbracoContext           = umbracoContext ?? throw new ArgumentNullException(nameof(umbracoContext));
            _urlProviders             = urlProviders;
            _variationContextAccessor = variationContextAccessor;

            Mode = mode;
        }
 /// <summary>
 ///     Initializes a new instance of the <see cref="PublishedContentQuery" /> class.
 /// </summary>
 public PublishedContentQuery(IPublishedSnapshot publishedSnapshot,
                              IVariationContextAccessor variationContextAccessor, IExamineManager examineManager)
 {
     _publishedSnapshot        = publishedSnapshot ?? throw new ArgumentNullException(nameof(publishedSnapshot));
     _variationContextAccessor = variationContextAccessor ??
                                 throw new ArgumentNullException(nameof(variationContextAccessor));
     _examineManager = examineManager ?? throw new ArgumentNullException(nameof(examineManager));
 }
Beispiel #26
0
 public ErrorPagesComponent(IUmbracoContextFactory contextFactory, IDomainService domainService, ILocalizationService localizationService, ILogger logger, IVariationContextAccessor variationContextAccessor)
 {
     _contextFactory      = contextFactory;
     _domainService       = domainService;
     _localizationService = localizationService;
     _logger = logger;
     _variationContextAccessor = variationContextAccessor;
 }
Beispiel #27
0
 public ErrorPageService(IUmbracoContextFactory contextFactory, IDomainService domainService, ILocalizationService localizationService, ILogger logger, IVariationContextAccessor variationContextAccessor, Uri originalRequest = null)
 {
     _contextFactory      = contextFactory;
     _domainService       = domainService;
     _localizationService = localizationService;
     _logger = logger;
     _variantContextAccessor = variationContextAccessor;
     _contextReference       = _contextFactory.EnsureUmbracoContext();
     _originalRequest        = originalRequest ?? _contextReference.UmbracoContext.HttpContext.Request.Url;
 }
Beispiel #28
0
 private PublishedMember(
     IMember member,
     ContentNode contentNode,
     ContentData contentData,
     IPublishedSnapshotAccessor publishedSnapshotAccessor,
     IVariationContextAccessor variationContextAccessor)
     : base(contentNode, contentData, publishedSnapshotAccessor, variationContextAccessor)
 {
     _member = member;
 }
Beispiel #29
0
        // TODO: figure this out
        // after the current snapshot has been resync-ed
        // it's too late for UmbracoContext which has captured previewDefault and stuff into these ctor vars
        // but, no, UmbracoContext returns snapshot.Content which comes from elements SO a resync should create a new cache

        public ContentCache(bool previewDefault, ContentStore.Snapshot snapshot, IAppCache snapshotCache, IAppCache elementsCache, IDomainCache domainCache, IGlobalSettings globalSettings, IVariationContextAccessor variationContextAccessor)
            : base(previewDefault)
        {
            _snapshot                 = snapshot;
            _snapshotCache            = snapshotCache;
            _elementsCache            = elementsCache;
            _domainCache              = domainCache;
            _globalSettings           = globalSettings;
            _variationContextAccessor = variationContextAccessor;
        }
Beispiel #30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ContentFinderByUrlAlias"/> class.
 /// </summary>
 public ContentFinderByUrlAlias(
     ILogger <ContentFinderByUrlAlias> logger,
     IPublishedValueFallback publishedValueFallback,
     IVariationContextAccessor variationContextAccessor,
     IUmbracoContextAccessor umbracoContextAccessor)
 {
     _publishedValueFallback   = publishedValueFallback;
     _variationContextAccessor = variationContextAccessor;
     _umbracoContextAccessor   = umbracoContextAccessor;
     _logger = logger;
 }