/// <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 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; }
public ComponentFactory(IComponentPresentationFactory componentPresentationFactory, IFactoryCommonServices factoryCommonServices) : base(factoryCommonServices) { if (componentPresentationFactory == null) { throw new ArgumentNullException("componentPresentationFactory"); } ComponentPresentationFactory = componentPresentationFactory; }
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; }
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; }
/// <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; }
//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; }
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; }
/// <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)); } }
public TridionControllerBase(IPageFactory pageFactory, IComponentPresentationFactory componentPresentationFactory, ILogger logger, IDD4TConfiguration dd4tConfiguration) : base(pageFactory, componentPresentationFactory, logger, dd4tConfiguration) { }
public ModelControllerBase(IPageFactory pageFactory, IComponentPresentationFactory componentPresentationFactory, ILogger logger, IDD4TConfiguration dd4tConfiguration, IViewModelFactory viewModelFactory) : base(pageFactory, componentPresentationFactory, logger, dd4tConfiguration) { this.ViewModelFactory = viewModelFactory; }