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

            options.Invoke(bindings);

            return(PartialContentView(controller, bindings));
        }
예제 #2
0
 public RenderingContext(ContentBindings contentBindings)
 {
     ContentType        = contentBindings.ContentType;
     ContentId          = contentBindings.ContentId;
     ContentVersionCode = contentBindings.VersionCode;
     ContentEditable    = contentBindings.Editable;
     ContentViewPath    = contentBindings.ViewPath;
     ContentViewModel   = contentBindings.ViewModel;
 }
예제 #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));
        }
예제 #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));
        }
예제 #5
0
        private static RenderingContext CreateGenericRenderingContext(string contentViewPath, object contentViewModel)
        {
            var bindings = new ContentBindings
            {
                ContentType = "Generic",
                ViewPath    = contentViewPath,
                ViewModel   = contentViewModel
            };

            return(new RenderingContext(bindings));
        }
예제 #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);
        }