Exemple #1
0
        public static IActionResult PartialContentView(this Controller controller, Action <ContentBindings> options)
        {
            var bindings = new ContentBindings();

            options.Invoke(bindings);

            return(PartialContentView(controller, bindings));
        }
 public RenderingContext(ContentBindings contentBindings)
 {
     ContentType        = contentBindings.ContentType;
     ContentId          = contentBindings.ContentId;
     ContentVersionCode = contentBindings.VersionCode;
     ContentEditable    = contentBindings.Editable;
     ContentViewPath    = contentBindings.ViewPath;
     ContentViewModel   = contentBindings.ViewModel;
 }
Exemple #3
0
        public static IActionResult PartialContentView(this Controller controller, ContentBindings contentBindings)
        {
            var services = controller.HttpContext.RequestServices;
            var context  = CreateBaseRenderingContext(services, contentBindings);

            SetRenderingContext(controller, context);

            return(controller.PartialView("/UI/Views/Rendering/PartialShell.cshtml", context));
        }
Exemple #4
0
        public static IActionResult MasterPageView(this Controller controller, ContentBindings contentBindings, ShellSettings shellSettings = null)
        {
            var services     = controller.HttpContext.RequestServices;
            var baseContext  = CreateBaseRenderingContext(services, contentBindings);
            var ShellContext = CreateMasterRenderingContext(services, baseContext, shellSettings);

            SetRenderingContext(controller, ShellContext);

            return(controller.View("/UI/Views/Rendering/MasterShell.cshtml", ShellContext));
        }
Exemple #5
0
        private static RenderingContext CreateGenericRenderingContext(string contentViewPath, object contentViewModel)
        {
            var bindings = new ContentBindings
            {
                ContentType = "Generic",
                ViewPath    = contentViewPath,
                ViewModel   = contentViewModel
            };

            return(new RenderingContext(bindings));
        }
Exemple #6
0
        private static RenderingContext CreateBaseRenderingContext(IServiceProvider services, ContentBindings contentBindings)
        {
            var contentManager   = services.GetService <ContentManager>();
            var renderingContext = new RenderingContext(contentBindings);

            if (!string.IsNullOrEmpty(contentBindings.ContentType) && !string.IsNullOrEmpty(contentBindings.ContentId) && contentBindings.ContentType != ContentBindings.GENERIC_CONTENT_TYPE)
            {
                var version = contentBindings.VersionCode == null
                    ? contentManager.GetPublishedVersionInfo(contentBindings.ContentType, contentBindings.ContentId).Result
                    : contentManager.GetVersionInfo(contentBindings.ContentType, contentBindings.ContentId, contentBindings.VersionCode).Result;

                if (version != null)
                {
                    renderingContext.ContentVersionInfo = ToVersionInfo(version);
                    renderingContext.ContentTreeId      = contentManager.GetContentTreeId(version).Result;
                }
            }

            return(renderingContext);
        }