This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PublicationResolver : IPublicationResolver | |
{ | |
private readonly DynamicMappingsRetriever _mappingsRetriever; | |
public PublicationResolver() | |
{ | |
_mappingsRetriever = new DynamicMappingsRetriever(); | |
} | |
public int ResolvePublicationId() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Tridion.ContentDelivery.DynamicContent | |
{ | |
public interface IPublicationMapping | |
{ | |
string Domain { get; } | |
string Path { get; } | |
int PathScanDepth { get; } | |
string Port { get; } | |
string Protocol { get; } | |
int PublicationId { get; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Diagnostics; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Web; | |
using Tridion.ContentDelivery.DynamicContent; | |
namespace SDlWeb8.Examples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ContentModel("product", true)] | |
public class Product : ViewModelBase | |
{ | |
[TextField] | |
public string Title { get; set; } | |
[ProductPrice(FieldName = "productId")] | |
public double Price { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ProductPriceFieldAttribute : FieldAttributeBase | |
{ | |
public override IEnumerable GetFieldValues(IField field, IModelProperty property, ITemplate template, IViewModelFactory factory) | |
{ | |
IEnumerable fieldValue = null; | |
var productId = field.Values.FirstOrDefault(); | |
var productService = new ProductService(); | |
var price = productService.GetProduct(productId).Price; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NLogModule : Module | |
{ | |
protected override void AttachToComponentRegistration(IComponentRegistry componentRegistry, IComponentRegistration registration) | |
{ | |
registration.Preparing += OnComponentPreparing; | |
} | |
private static void OnComponentPreparing(object sender, PreparingEventArgs e) | |
{ | |
var t = e.Component.Activator.LimitType; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PageController : TridionControllerBase | |
{ | |
public PageController(IPageFactory pageFactor, | |
IComponentPresentationFactory componentPresentationFactory, | |
ILogger logger, | |
IDD4TConfiguration configuration) : | |
base(pageFactor, componentPresentationFactory, logger, configuration) | |
{ | |
public override ActionResult Page(string url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MvcApplication : System.Web.HttpApplication | |
{ | |
ILifetimeScope BuildContainer() | |
{ | |
var builder = new ContainerBuilder(); | |
builder.RegisterControllers(typeof(MvcApplication).Assembly); | |
builder.UseDD4T(); | |
return builder.Build(); | |
} | |
protected void Application_Start() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
routes.MapRoute( | |
name: "TridionPage", | |
url: "{*PageUrl}", | |
defaults: new { controller = "Page", action = "Page" } | |
); | |
routes.MapRoute( | |
name: "Default", | |
url: "{controller}/{action}/{id}", | |
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ILifetimeScope BuildContainer() | |
{ | |
var builder = new ContainerBuilder(); | |
builder.RegisterType<HttpClientAuthentication>() | |
.As<DD4T.Providers.Rest.IHttpMessageHandlerFactory>(); | |
builder.UseDD4T(); | |
} |
NewerOlder