protected override IEnumerable <Rendering> GetRenderings( XElement layoutDefinition, BuildPageDefinitionArgs args) { // replaced parser with custom one XmlBasedRenderingParser parser = new CDNXmlBasedRenderingParser(); foreach (XElement element1 in layoutDefinition.Elements("d")) { XElement deviceNode = element1; Guid deviceId = deviceNode.GetAttributeValueOrEmpty("id").ToGuid(); // replace layout with CDN layout Guid layoutId = RequestExtensions.IsContextRequestForDynamicData() ? Guid.Parse(Constants.Layout.DefaultCDNLayoutId) : deviceNode.GetAttributeValueOrEmpty("l").ToGuid(); IEnumerable <RenderingInfo> dynamicRenderingsInfo = RequestExtensions.GetDynamicRenderingsInfo(); yield return(this.GetRendering(deviceNode, deviceId, layoutId, "Layout", parser)); foreach (XElement element2 in deviceNode.Elements("r")) { // replacing placeholders to match CDN layout placeholder keys var rendering = this.GetRendering(element2, deviceId, layoutId, element2.Name.LocalName, parser); if (RequestExtensions.IsContextRequestForDynamicData()) { var idMatchRendering = dynamicRenderingsInfo .FirstOrDefault(r => r.RenderingId.ToGuid().Equals(rendering.UniqueId)); if (idMatchRendering != null) { rendering["Placeholder"] = Constants.Layout.DefaultCDNPlaceholder; } else { var placeholderMatchRendering = dynamicRenderingsInfo .FirstOrDefault( r => rendering.Placeholder.StartsWith(r.Placeholder) && !rendering.Placeholder.Equals(r.Placeholder)); if (placeholderMatchRendering != null) { rendering["Placeholder"] = rendering["Placeholder"] .Replace( placeholderMatchRendering.Placeholder.TrimStart('/'), Constants.Layout.DefaultCDNPlaceholder); } } } yield return(rendering); } } }
public override void Process(RenderRenderingArgs args) { if (RequestExtensions.IsContextRequestForDynamicData() && Context.PageMode.IsNormal && args.Rendering != null && args.Rendering.RenderingType != "Layout" && args.Rendering.Placeholder.Equals(CDN.Constants.Layout.DefaultCDNPlaceholder)) { args.Writer.Write($"<div data-rendering-id=\"{args.Rendering.UniqueId}\">"); } }
public override void Process(ActionExecutedArgs args) { if (RequestExtensions.IsContextRequestForDynamicData()) { // no cache for dynamic data args.Context.RequestContext.HttpContext.Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache); } else { // all pages are cached for 1 minute args.Context.RequestContext.HttpContext.Response.Cache.SetCacheability(System.Web.HttpCacheability.Public); args.Context.RequestContext.HttpContext.Response.Cache.SetMaxAge(TimeSpan.FromMinutes(1)); } }
public override void Process(GetRendererArgs args) { if (args.Result != null) { return; } if (Context.PageMode.IsNormal && !RequestExtensions.IsContextRequestForDynamicData() && args.Rendering.IsAlwaysDynamicallyLoaded()) { args.Result = this.GetRenderer(args.Rendering, args); } }