protected IBlock GetBlock(bool allowNoContextFound = true) { var wrapLog = Log.Call <IBlock>(parameters: $"request:..., {nameof(allowNoContextFound)}: {allowNoContextFound}"); var containerId = GetTypedHeader(Sxc.WebApi.WebApiConstants.HeaderInstanceId, -1); var contentblockId = GetTypedHeader(Sxc.WebApi.WebApiConstants.HeaderContentBlockId, 0); // this can be negative, so use 0 var pageId = GetTypedHeader(Sxc.WebApi.WebApiConstants.HeaderPageId, -1); var instance = TestIds.FindInstance(containerId); if (containerId == -1 || pageId == -1 || instance == null) { if (allowNoContextFound) { return(wrapLog("not found", null)); } throw new Exception("No context found, cannot continue"); } var ctx = SxcMvc.CreateContext(HttpContext.RequestServices, instance.Zone, pageId, containerId, instance.App, instance.Block); IBlock block = HttpContext.RequestServices.Build <BlockFromModule>().Init(ctx, Log); // only if it's negative, do we load the inner block if (contentblockId > 0) { return(wrapLog("found", block)); } Log.Add($"Inner Content: {contentblockId}"); block = HttpContext.RequestServices.Build <BlockFromEntity>().Init(block, contentblockId, Log); return(wrapLog("found", block)); }
public Render2Model(IRenderRazor renderer, SxcMvc sxcMvc) { _renderer = renderer; _sxcMvc = sxcMvc; }