/// <summary>
        /// Gets an Entity Model for a given Entity Identifier.
        /// </summary>
        /// <param name="id">The Entity Identifier in format ComponentID-TemplateID.</param>
        /// <param name="localization">The context Localization.</param>
        /// <returns>The Entity Model.</returns>
        /// <exception cref="DxaItemNotFoundException">If no Entity Model exists for the given URL.</exception>
        /// <remarks>
        /// Since we can't obtain CT metadata for DCPs, we obtain the View Name from the CT Title.
        /// </remarks>
        public virtual EntityModel GetEntityModel(string id, Localization localization)
        {
            using (new Tracer(id, localization))
            {
                string[] idParts = id.Split('-');
                if (idParts.Length != 2)
                {
                    throw new DxaException(String.Format("Invalid Entity Identifier '{0}'. Must be in format ComponentID-TemplateID.", id));
                }

                string componentUri = string.Format("tcm:{0}-{1}", localization.LocalizationId, idParts[0]);
                string templateUri  = string.Format("tcm:{0}-{1}-32", localization.LocalizationId, idParts[1]);

                IComponentPresentationFactory componentPresentationFactory = DD4TFactoryCache.GetComponentPresentationFactory(localization);
                IComponentPresentation        dcp;
                if (!componentPresentationFactory.TryGetComponentPresentation(out dcp, componentUri, templateUri))
                {
                    throw new DxaItemNotFoundException(id, localization.LocalizationId);
                }

                EntityModel result = ModelBuilderPipeline.CreateEntityModel(dcp, localization);
                if (result.XpmMetadata != null)
                {
                    // Entity Models requested through this method are per definition "query based" in XPM terminology.
                    result.XpmMetadata["IsQueryBased"] = true;
                }
                return(result);
            }
        }
 public PageController(IPageFactory pageFactor,
                       IComponentPresentationFactory componentPresentationFactory,
                       ILogger logger,
                       IDD4TConfiguration configuration) :
     base(pageFactor, componentPresentationFactory, logger, configuration)
 {
 }
        public PageController(IPageFactory pageFactor, 
                                IComponentPresentationFactory componentPresentationFactory, 
                                ILogger logger, 
                                IDD4TConfiguration configuration) :
            base(pageFactor, componentPresentationFactory, logger, configuration)
        {

        }
示例#4
0
        public ComponentFactory( IComponentPresentationFactory componentPresentationFactory,
                            IFactoriesFacade facade)
            : base(facade)
        {
            if (componentPresentationFactory == null)
                throw new ArgumentNullException("componentPresentationFactory");

            ComponentPresentationFactory = componentPresentationFactory;
        }
        public ComponentFactory( IComponentPresentationFactory componentPresentationFactory,
                            IFactoryCommonServices factoryCommonServices)
            : base(factoryCommonServices)
        {

            if (componentPresentationFactory == null)
                throw new ArgumentNullException("componentPresentationFactory");

            ComponentPresentationFactory = componentPresentationFactory;
        }
        public ComponentFactory(IComponentPresentationFactory componentPresentationFactory,
                                IFactoriesFacade facade)
            : base(facade)
        {
            if (componentPresentationFactory == null)
            {
                throw new ArgumentNullException("componentPresentationFactory");
            }

            ComponentPresentationFactory = componentPresentationFactory;
        }
示例#7
0
        public ComponentFactory(IComponentPresentationFactory componentPresentationFactory,
                                IFactoryCommonServices factoryCommonServices)
            : base(factoryCommonServices)
        {
            if (componentPresentationFactory == null)
            {
                throw new ArgumentNullException("componentPresentationFactory");
            }

            ComponentPresentationFactory = componentPresentationFactory;
        }
示例#8
0
        public PageFactory(IPageProvider pageProvider, IComponentPresentationFactory componentPresentationFactory,
                            IFactoriesFacade facade)
            : base(facade)
        {
            if (pageProvider == null)
                throw new ArgumentNullException("pageProvider");

            if (componentPresentationFactory == null)
                throw new ArgumentNullException("componentPresentationFactory");

            ComponentPresentationFactory = componentPresentationFactory;
            PageProvider = pageProvider;
        }
示例#9
0
        public PageFactory(IPageProvider pageProvider, IComponentPresentationFactory componentPresentationFactory,
                           IFactoryCommonServices factoryCommonServices)
            : base(factoryCommonServices)
        {
            if (pageProvider == null)
            {
                throw new ArgumentNullException("pageProvider");
            }

            if (componentPresentationFactory == null)
            {
                throw new ArgumentNullException("componentPresentationFactory");
            }

            ComponentPresentationFactory = componentPresentationFactory;
            PageProvider = pageProvider;
        }
示例#10
0
        /// <summary>
        /// Gets an Entity Model for a given Entity Identifier.
        /// </summary>
        /// <param name="id">The Entity Identifier in format ComponentID-TemplateID.</param>
        /// <param name="localization">The context Localization.</param>
        /// <returns>The Entity Model.</returns>
        /// <exception cref="DxaItemNotFoundException">If no Entity Model exists for the given URL.</exception>
        /// <remarks>
        /// Since we can't obtain CT metadata for DCPs, we obtain the View Name from the CT Title.
        /// </remarks>
        public virtual EntityModel GetEntityModel(string id, Localization localization)
        {
            using (new Tracer(id, localization))
            {
                string[] idParts = id.Split('-');
                if (idParts.Length != 2)
                {
                    throw new DxaException(String.Format("Invalid Entity Identifier '{0}'. Must be in format ComponentID-TemplateID.", id));
                }

                string componentUri = localization.GetCmUri(idParts[0]);
                string templateUri  = localization.GetCmUri(idParts[1], (int)ItemType.ComponentTemplate);

                IComponentPresentationFactory componentPresentationFactory = DD4TFactoryCache.GetComponentPresentationFactory(localization);
                IComponentPresentation        dcp;
                if (!componentPresentationFactory.TryGetComponentPresentation(out dcp, componentUri, templateUri))
                {
                    throw new DxaItemNotFoundException(id, localization.Id);
                }

                EntityModel result;
                if (CacheRegions.IsViewModelCachingEnabled)
                {
                    EntityModel cachedEntityModel = SiteConfiguration.CacheProvider.GetOrAdd(
                        string.Format("{0}-{1}", id, localization.Id), // key
                        CacheRegions.EntityModel,
                        () => ModelBuilderPipeline.CreateEntityModel(dcp, localization),
                        dependencies: new[] { componentUri }
                        );

                    // Don't return the cached Entity Model itself, because we don't want dynamic logic to modify the cached state.
                    result = (EntityModel)cachedEntityModel.DeepCopy();
                }
                else
                {
                    result = ModelBuilderPipeline.CreateEntityModel(dcp, localization);
                }

                if (result.XpmMetadata != null)
                {
                    // Entity Models requested through this method are per definition "query based" in XPM terminology.
                    result.XpmMetadata["IsQueryBased"] = true;
                }
                return(result);
            }
        }
        public TridionBackedCacheAgent(IDD4TConfiguration configuration, ILogger logger, IPageFactory pageFactory, IComponentPresentationFactory componentpresentationFactory)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }

            _logger        = logger;
            _configuration = configuration;
            _pageFactory   = pageFactory;
            _componentPresentationFactory = componentpresentationFactory;
        }
示例#12
0
        //private readonly IExtendedPublicationResolver _publicationResolver;

        public DefaultContentProvider(IPageFactory pageFactory,
                                      IComponentPresentationFactory componentPresentationFactory,
                                      IViewModelFactory viewModelFactory,
                                      ILogger logger,
                                      //IExtendedPublicationResolver publicationResolver,
                                      IDD4TConfiguration configuration)
        {
            pageFactory.ThrowIfNull(nameof(pageFactory));
            viewModelFactory.ThrowIfNull(nameof(viewModelFactory));
            logger.ThrowIfNull(nameof(logger));
            componentPresentationFactory.ThrowIfNull(nameof(componentPresentationFactory));
            configuration.ThrowIfNull(nameof(configuration));
            //publicationResolver.ThrowIfNull(nameof(publicationResolver));

            //this._publicationResolver = publicationResolver;
            this._pageFactory                  = pageFactory;
            this._viewModelFactory             = viewModelFactory;
            this._componentPresentationFactory = componentPresentationFactory;
            this._logger        = logger;
            this._configuration = configuration;
        }
示例#13
0
        public DD4TControllerBase(IPageFactory pageFactory, IComponentPresentationFactory componentPresentationFactory, ILogger logger, IDD4TConfiguration dd4tConfiguration)
        {
            if (pageFactory == null)
            {
                throw new ArgumentNullException("pageFactory");
            }

            if (componentPresentationFactory == null)
            {
                throw new ArgumentNullException("componentPresentationFactory");
            }

            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }

            LoggerService = logger;
            PageFactory   = pageFactory;
            ComponentPresentationFactory = componentPresentationFactory;
            DD4TConfiguration            = dd4tConfiguration;
        }
示例#14
0
        /// <summary>
        /// Gets an Entity Model for a given Entity Identifier.
        /// </summary>
        /// <param name="id">The Entity Identifier in format ComponentID-TemplateID.</param>
        /// <param name="localization">The context Localization.</param>
        /// <returns>The Entity Model.</returns>
        /// <exception cref="DxaItemNotFoundException">If no Entity Model exists for the given URL.</exception>
        /// <remarks>
        /// Since we can't obtain CT metadata for DCPs, we obtain the View Name from the CT Title.
        /// </remarks>
        public virtual EntityModel GetEntityModel(string id, Localization localization)
        {
            using (new Tracer(id, localization))
            {
                string[] idParts = id.Split('-');
                if (idParts.Length != 2)
                {
                    throw new DxaException(String.Format("Invalid Entity Identifier '{0}'. Must be in format ComponentID-TemplateID.", id));
                }

                string componentUri = string.Format("tcm:{0}-{1}", localization.LocalizationId, idParts[0]);
                string templateUri  = string.Format("tcm:{0}-{1}-32", localization.LocalizationId, idParts[1]);

                IComponentPresentationFactory componentPresentationFactory = DD4TFactoryCache.GetComponentPresentationFactory(localization);
                IComponentPresentation        dcp;
                if (!componentPresentationFactory.TryGetComponentPresentation(out dcp, componentUri, templateUri))
                {
                    throw new DxaItemNotFoundException(id);
                }

                return(ModelBuilderPipeline.CreateEntityModel(dcp, localization));
            }
        }
示例#15
0
 public TridionControllerBase(IPageFactory pageFactory, IComponentPresentationFactory componentPresentationFactory, ILogger logger, IDD4TConfiguration dd4tConfiguration) : base(pageFactory, componentPresentationFactory, logger, dd4tConfiguration)
 {
 }
示例#16
0
 public ModelControllerBase(IPageFactory pageFactory, IComponentPresentationFactory componentPresentationFactory, ILogger logger, IDD4TConfiguration dd4tConfiguration, IViewModelFactory viewModelFactory) : base(pageFactory, componentPresentationFactory, logger, dd4tConfiguration)
 {
     this.ViewModelFactory = viewModelFactory;
 }
示例#17
0
 public TridionControllerBase(IPageFactory pageFactory, IComponentPresentationFactory componentPresentationFactory, ILogger logger, IDD4TConfiguration dd4tConfiguration) : base(pageFactory, componentPresentationFactory, logger, dd4tConfiguration)
 {
 }
示例#18
0
 public ModelControllerBase(IPageFactory pageFactory, IComponentPresentationFactory componentPresentationFactory, ILogger logger, IDD4TConfiguration dd4tConfiguration, IViewModelFactory viewModelFactory) : base(pageFactory, componentPresentationFactory, logger, dd4tConfiguration)
 {
     this.ViewModelFactory = viewModelFactory;
 }