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;
        }
예제 #2
0
 public UmbracoServices(IContentTypeService contentTypeService, IMediaTypeService mediaTypeService, IMemberTypeService memberTypeService, IPublishedContentTypeFactory publishedContentTypeFactory)
 {
     _contentTypeService          = contentTypeService;
     _mediaTypeService            = mediaTypeService;
     _memberTypeService           = memberTypeService;
     _publishedContentTypeFactory = publishedContentTypeFactory;
 }
 // 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;
 }
예제 #4
0
 // default ctor
 internal PublishedContentTypeCache(IContentTypeService contentTypeService, IMediaTypeService mediaTypeService, IMemberTypeService memberTypeService, IPublishedContentTypeFactory publishedContentTypeFactory, ILogger logger)
 {
     _contentTypeService          = contentTypeService;
     _mediaTypeService            = mediaTypeService;
     _memberTypeService           = memberTypeService;
     _logger                      = logger;
     _publishedContentTypeFactory = publishedContentTypeFactory;
 }
 // default ctor
 public PublishedContentTypeCache(IContentTypeService?contentTypeService, IMediaTypeService?mediaTypeService, IMemberTypeService?memberTypeService, IPublishedContentTypeFactory publishedContentTypeFactory, ILogger <PublishedContentTypeCache> logger)
 {
     _contentTypeService          = contentTypeService;
     _mediaTypeService            = mediaTypeService;
     _memberTypeService           = memberTypeService;
     _logger                      = logger;
     _publishedContentTypeFactory = publishedContentTypeFactory;
 }
예제 #6
0
 public PublishedElementHelper()
 {
     _contentTypeService          = Current.Services.ContentTypeService;
     _publishedContentTypeFactory = Current.PublishedContentTypeFactory;
     _logger                = Current.Logger;
     _dataTypeService       = Current.Services.DataTypeService;
     _publishedModelFactory = Current.Factory.GetInstance <IPublishedModelFactory>();
     _propertyEditors       = Current.PropertyEditors;
 }
 public PreviewController(
     IProfilingLogger profilingLogger,
     IPublishedContentTypeFactory publishedContentTypeFactory,
     IPublishedModelFactory publishedModelFactory,
     IPublishedSnapshotAccessor publishedSnapshotAccessor)
 {
     _profilingLogger             = profilingLogger;
     _publishedContentTypeFactory = publishedContentTypeFactory;
     _publishedModelFactory       = publishedModelFactory;
     _publishedSnapshotAccessor   = publishedSnapshotAccessor;
 }
예제 #8
0
 public DocTypeGridEditorHelper(AppCaches appCaches, IUmbracoContextAccessor umbracoContextAccessor, PropertyEditorCollection dataEditors, ILoggerFactory loggerFactory, IDataTypeService dataTypeService, IPublishedModelFactory publishedModelFactory, IContentTypeService contentTypeService, IPublishedContentTypeFactory publishedContentTypeFactory)
 {
     _appCaches                   = appCaches;
     _umbracoContext              = umbracoContextAccessor;
     _dataEditors                 = dataEditors;
     _logger                      = loggerFactory.CreateLogger <DocTypeGridEditorHelper>();
     _dataTypeService             = dataTypeService;
     _publishedModelFactory       = publishedModelFactory;
     _contentTypeService          = contentTypeService;
     _publishedContentTypeFactory = publishedContentTypeFactory;
 }
예제 #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UmbracoServices"/> class.
 /// </summary>
 public UmbracoServices(
     IContentTypeService contentTypeService,
     IMediaTypeService mediaTypeService,
     IMemberTypeService memberTypeService,
     IPublishedContentTypeFactory publishedContentTypeFactory,
     IShortStringHelper shortStringHelper)
 {
     _contentTypeService          = contentTypeService;
     _mediaTypeService            = mediaTypeService;
     _memberTypeService           = memberTypeService;
     _publishedContentTypeFactory = publishedContentTypeFactory;
     _shortStringHelper           = shortStringHelper;
 }
예제 #10
0
 public PreviewController(
     IProfilingLogger profilingLogger,
     IPublishedContentTypeFactory publishedContentTypeFactory,
     IPublishedModelFactory publishedModelFactory,
     IPublishedSnapshotAccessor publishedSnapshotAccessor,
     BlockEditorConverter blockConverter)
 {
     _profilingLogger             = profilingLogger;
     _publishedContentTypeFactory = publishedContentTypeFactory;
     _publishedModelFactory       = publishedModelFactory;
     _publishedSnapshotAccessor   = publishedSnapshotAccessor;
     _blockConverter = blockConverter;
     _blockListEditorDataConverter = new BlockListEditorDataConverter();
 }
예제 #11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PublishedContentType"/> class with a content type.
        /// </summary>
        public PublishedContentType(IContentTypeComposition contentType, IPublishedContentTypeFactory factory)
            : this(contentType.Id, contentType.Alias, contentType.GetItemType(), contentType.CompositionAliases(), contentType.Variations, contentType.IsElement)
        {
            var propertyTypes = contentType.CompositionPropertyTypes
                                .Select(x => factory.CreatePropertyType(this, x))
                                .ToList();

            if (ItemType == PublishedItemType.Member)
            {
                EnsureMemberProperties(propertyTypes, factory);
            }

            _propertyTypes = propertyTypes.ToArray();

            InitializeIndexes();
        }
        public UnpublishedContent(IContent content, ServiceContext serviceContext, IPublishedContentTypeFactory publishedContentTypeFactory, PropertyEditorCollection propertyEditors)
            : base()
        {
            var userService = new Lazy <IUserService>(() => serviceContext.UserService);

            _publishedContentTypeFactory = publishedContentTypeFactory;
            _propertyEditors             = propertyEditors;

            this.content = content;
            var contentType = serviceContext.ContentTypeService.Get(this.content.ContentType.Id);

            //this.children = new Lazy<IEnumerable<IPublishedContent>>(() => this.content.Children().Select(x => new UnpublishedContent(x, serviceContext)).ToList());
            this.contentType = new Lazy <IPublishedContentType>(() => _publishedContentTypeFactory.CreateContentType(contentType));
            this.creatorName = new Lazy <string>(() => this.content.GetCreatorProfile(userService.Value).Name);
            this.parent      = new Lazy <IPublishedContent>(() => new UnpublishedContent(serviceContext.ContentService.GetById(this.content.ParentId), serviceContext, _publishedContentTypeFactory, _propertyEditors));
            this.properties  = new Lazy <Dictionary <string, IPublishedProperty> >(() => MapProperties(serviceContext));
            this.urlName     = new Lazy <string>(() => this.content.Name.ToUrlSegment());
            this.writerName  = new Lazy <string>(() => this.content.GetWriterProfile(userService.Value).Name);
        }
        // used in some tests
        internal 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,
            PublishedContentTypeCache contentTypeCache,
            MainDom mainDom,
            bool testing,
            bool enableRepositoryEvents)
        {
            _routesCache = new RoutesCache();
            _publishedContentTypeFactory = publishedContentTypeFactory;
            _contentTypeCache            = contentTypeCache
                                           ?? new PublishedContentTypeCache(serviceContext.ContentTypeService, serviceContext.MediaTypeService, serviceContext.MemberTypeService, publishedContentTypeFactory, loggerFactory.CreateLogger <PublishedContentTypeCache>());

            _xmlStore = new XmlStore(serviceContext.ContentTypeService, serviceContext.ContentService, scopeProvider, _routesCache,
                                     _contentTypeCache, publishedSnapshotAccessor, mainDom, testing, enableRepositoryEvents,
                                     documentRepository, mediaRepository, memberRepository, entitySerializer, hostingEnvironment, hostingLifetime, shortStringHelper);

            _domainService            = serviceContext.DomainService;
            _mediaService             = serviceContext.MediaService;
            _userService              = serviceContext.UserService;
            _defaultCultureAccessor   = defaultCultureAccessor;
            _variationContextAccessor = variationContextAccessor;
            _requestCache             = requestCache;
            _umbracoContextAccessor   = umbracoContextAccessor;
            _globalSettings           = globalSettings;
            _entitySerializer         = entitySerializer;
        }
 // used in some tests
 internal PublishedSnapshotService(ServiceContext serviceContext,
                                   IPublishedContentTypeFactory publishedContentTypeFactory,
                                   IScopeProvider scopeProvider,
                                   ICacheProvider requestCache,
                                   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)
     : this(serviceContext, publishedContentTypeFactory, scopeProvider, requestCache, Enumerable.Empty <IUrlSegmentProvider>(),
            publishedSnapshotAccessor, variationContextAccessor,
            documentRepository, mediaRepository, memberRepository,
            defaultCultureAccessor,
            logger, globalSettings, siteDomainHelper, contentTypeCache, mainDom, testing, enableRepositoryEvents)
 {
 }
예제 #15
0
 // 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,
                                    ILogger logger,
                                    IGlobalSettings globalSettings,
                                    ISiteDomainHelper siteDomainHelper,
                                    IEntityXmlSerializer entitySerializer,
                                    MainDom mainDom,
                                    bool testing = false, bool enableRepositoryEvents = true)
     : this(serviceContext, publishedContentTypeFactory, scopeProvider, requestCache,
            publishedSnapshotAccessor, variationContextAccessor, umbracoContextAccessor,
            documentRepository, mediaRepository, memberRepository,
            defaultCultureAccessor,
            logger, globalSettings, siteDomainHelper, entitySerializer, null, mainDom, testing, enableRepositoryEvents)
 {
     _umbracoContextAccessor = umbracoContextAccessor;
 }
예제 #16
0
 public PublishedSnapshotService(
     PublishedSnapshotServiceOptions options,
     ISyncBootStateAccessor syncBootStateAccessor,
     IMainDom mainDom,
     ServiceContext serviceContext,
     IPublishedContentTypeFactory publishedContentTypeFactory,
     IPublishedSnapshotAccessor publishedSnapshotAccessor,
     IVariationContextAccessor variationContextAccessor,
     IProfilingLogger profilingLogger,
     ILoggerFactory loggerFactory,
     IScopeProvider scopeProvider,
     INuCacheContentService publishedContentService,
     IDefaultCultureAccessor defaultCultureAccessor,
     IOptions <GlobalSettings> globalSettings,
     IPublishedModelFactory publishedModelFactory,
     IHostingEnvironment hostingEnvironment,
     IOptions <NuCacheSettings> config,
     ContentDataSerializer contentDataSerializer)
 {
     _options = options;
     _syncBootStateAccessor = syncBootStateAccessor;
     _mainDom        = mainDom;
     _serviceContext = serviceContext;
     _publishedContentTypeFactory = publishedContentTypeFactory;
     _publishedSnapshotAccessor   = publishedSnapshotAccessor;
     _variationContextAccessor    = variationContextAccessor;
     _profilingLogger             = profilingLogger;
     _loggerFactory           = loggerFactory;
     _logger                  = _loggerFactory.CreateLogger <PublishedSnapshotService>();
     _scopeProvider           = scopeProvider;
     _publishedContentService = publishedContentService;
     _defaultCultureAccessor  = defaultCultureAccessor;
     _globalSettings          = globalSettings.Value;
     _hostingEnvironment      = hostingEnvironment;
     _contentDataSerializer   = contentDataSerializer;
     _config                  = config.Value;
     _publishedModelFactory   = publishedModelFactory;
 }
예제 #17
0
 public DocTypeGridEditorApiController(IUmbracoContextAccessor umbracoContext,
                                       IContentTypeService contentTypeService,
                                       IContentService contentService,
                                       IDataTypeService dataTypeService,
                                       IShortStringHelper shortStringHelper,
                                       IPublishedContentQuery contentQuery,
                                       IPublishedRouter router,
                                       ServiceContext serviceContext,
                                       IPublishedContentTypeFactory publishedContentTypeFactory,
                                       PropertyEditorCollection propertyEditorCollection,
                                       DocTypeGridEditorHelper dtgeHelper)
 {
     _umbracoContext              = umbracoContext;
     _contentTypeService          = contentTypeService;
     _contentService              = contentService;
     _dataTypeService             = dataTypeService;
     _shortStringHelper           = shortStringHelper;
     _contentQuery                = contentQuery;
     _router                      = router;
     _dtgeHelper                  = dtgeHelper;
     _serviceContext              = serviceContext;
     _publishedContentTypeFactory = publishedContentTypeFactory;
     _propertyEditorCollection    = propertyEditorCollection;
 }
        /// <summary>
        /// This constructor is for tests and is not intended to be used directly from application code.
        /// </summary>
        /// <remarks>
        /// <para>Values are assumed to be consistent and are not checked.</para>
        /// <para>The new published property type does not belong to a published content type.</para>
        /// </remarks>
        public PublishedPropertyType(string propertyTypeAlias, int dataTypeId, bool isUserProperty, ContentVariation variations, PropertyValueConverterCollection propertyValueConverters, IPublishedModelFactory publishedModelFactory, IPublishedContentTypeFactory factory)
        {
            _publishedModelFactory   = publishedModelFactory ?? throw new ArgumentNullException(nameof(publishedModelFactory));
            _propertyValueConverters = propertyValueConverters ?? throw new ArgumentNullException(nameof(propertyValueConverters));

            Alias = propertyTypeAlias;

            IsUserProperty = isUserProperty;
            Variations     = variations;

            DataType = factory.GetDataType(dataTypeId);
        }
 public UnpublishedContent(int id, ServiceContext serviceContext, IPublishedContentTypeFactory publishedContentTypeFactory, PropertyEditorCollection propertyEditors)
     : this(serviceContext.ContentService.GetById(id), serviceContext, publishedContentTypeFactory, propertyEditors)
 {
 }
        // for unit tests ONLY
#pragma warning disable CS8618
        internal PublishedContentTypeCache(ILogger <PublishedContentTypeCache> logger, IPublishedContentTypeFactory publishedContentTypeFactory)
#pragma warning restore CS8618
        {
            _logger = logger;
            _publishedContentTypeFactory = publishedContentTypeFactory;
        }
예제 #21
0
 // for unit tests ONLY
 internal PublishedContentTypeCache(ILogger logger, IPublishedContentTypeFactory publishedContentTypeFactory)
 {
     _logger = logger;
     _publishedContentTypeFactory = publishedContentTypeFactory;
 }
 public UnpublishedContent(int id, IContentService contentService, IContentTypeService contentTypeService, IDataTypeService dataTypeService, PropertyEditorCollection propertyEditorCollection, IPublishedContentTypeFactory publishedContentTypeFactory)
     : this(contentService.GetById(id), contentService, contentTypeService, dataTypeService, propertyEditorCollection, publishedContentTypeFactory)
 {
 }
 /// <summary>
 /// This constructor is for tests and is not intended to be used directly from application code.
 /// </summary>
 /// <remarks>
 /// <para>Values are assumed to be consisted and are not checked.</para>
 /// <para>The new published property type belongs to the published content type.</para>
 /// </remarks>
 public PublishedPropertyType(PublishedContentType contentType, string propertyTypeAlias, int dataTypeId, bool isUserProperty, ContentVariation variations, PropertyValueConverterCollection propertyValueConverters, IPublishedModelFactory publishedModelFactory, IPublishedContentTypeFactory factory)
     : this(propertyTypeAlias, dataTypeId, isUserProperty, variations, propertyValueConverters, publishedModelFactory, factory)
 {
     ContentType = contentType ?? throw new ArgumentNullException(nameof(contentType));
 }
 /// <summary>
 /// Initialize a new instance of the <see cref="PublishedPropertyType"/> class with a property type.
 /// </summary>
 /// <remarks>
 /// <para>The new published property type belongs to the published content type.</para>
 /// </remarks>
 public PublishedPropertyType(PublishedContentType contentType, PropertyType propertyType, PropertyValueConverterCollection propertyValueConverters, IPublishedModelFactory publishedModelFactory, IPublishedContentTypeFactory factory)
     : this(propertyType.Alias, propertyType.DataTypeId, true, propertyType.Variations, propertyValueConverters, publishedModelFactory, factory)
 {
     ContentType = contentType ?? throw new ArgumentNullException(nameof(contentType));
 }
예제 #25
0
        // Members have properties such as IMember LastLoginDate which are plain C# properties and not content
        // properties; they are exposed as pseudo content properties, as long as a content property with the
        // same alias does not exist already.
        private void EnsureMemberProperties(List <IPublishedPropertyType> propertyTypes, IPublishedContentTypeFactory factory)
        {
            var aliases = new HashSet <string>(propertyTypes.Select(x => x.Alias), StringComparer.OrdinalIgnoreCase);

            foreach (var(alias, dataTypeId) in BuiltinMemberProperties)
            {
                if (aliases.Contains(alias))
                {
                    continue;
                }
                propertyTypes.Add(factory.CreateCorePropertyType(this, alias, dataTypeId, ContentVariation.Nothing));
            }
        }
        public UnpublishedContent(IContent content, IContentService contentService, IContentTypeService contentTypeService, IDataTypeService dataTypeService, PropertyEditorCollection propertyEditorCollection, IPublishedContentTypeFactory publishedContentTypeFactory)
            : base()
        {
            this.content = content;
            var contentType = contentTypeService.Get(this.content.ContentType.Id);

            //this.children = new Lazy<IEnumerable<IPublishedContent>>(() => this.content.Children().Select(x => new UnpublishedContent(x, serviceContext)).ToList());
            this.contentType = new Lazy <IPublishedContentType>(() => publishedContentTypeFactory.CreateContentType(contentType));
            this.parent      = new Lazy <IPublishedContent>(() => new UnpublishedContent(contentService.GetById(this.content.ParentId), contentService, contentTypeService, dataTypeService, propertyEditorCollection, publishedContentTypeFactory));
            this.properties  = new Lazy <Dictionary <string, IPublishedProperty> >(() => MapProperties(dataTypeService, propertyEditorCollection));
            //this.urlName = new Lazy<string>(() => this.content.Name.ToUrlSegment());
            //this.writerName = new Lazy<string>(() => this.content.GetWriterProfile(userService.Value).Name);
        }