Render MVC ViewModel without turnkey
(Created page with "MDriven Turnkey does a lot to get a seamless environment for application development. If you would like to make use of parts of the functionality and render a specific viewmo...")
 
No edit summary
Line 4: Line 4:


This is how turnkey does it internally:
This is how turnkey does it internally:
here
<nowiki>
  internal static class MvcRazorPartialViewShared
  {
    internal static string RenderRazorPartial(ViewModel.Runtime.ViewModel viewModel)
    {
      StringBuilder sb = new StringBuilder(2048); // Building big things!
                                                  // IMPORTANT! The Using and statements should match the one in the main page!
      sb.AppendLine("@using Eco.ViewModel.Runtime");
      sb.AppendLine("@using Eco.MVC");
      sb.AppendLine("@using StreamingAppGenericAPIAndControllers");
      sb.AppendLine("@model VMClass");
      RazorControlRenderer razorRenderer = new RazorControlRenderer();
      if (RenderSettings.CheckUseCSSGrid(viewModel))
      {
        CSSGridViewUICreator cssGridViewCreator = new CSSGridViewUICreator(razorRenderer, sb);
        ViewModelRTCreator.CreateDataAndUI(null, cssGridViewCreator, viewModel);
      }
      else
      {
        BootstrapViewUICreator bootstrapViewCreator = new BootstrapViewUICreator(razorRenderer, sb);
        ViewModelRTCreator.CreateDataAndUI(null, bootstrapViewCreator, viewModel); // Create UI delegating work to UICreator
      }
      return sb.ToString();
    }
  }
</nowiki>

Revision as of 12:32, 22 April 2019

MDriven Turnkey does a lot to get a seamless environment for application development.

If you would like to make use of parts of the functionality and render a specific viewmodel you can do so.

This is how turnkey does it internally: internal static class MvcRazorPartialViewShared { internal static string RenderRazorPartial(ViewModel.Runtime.ViewModel viewModel) { StringBuilder sb = new StringBuilder(2048); // Building big things! // IMPORTANT! The Using and statements should match the one in the main page! sb.AppendLine("@using Eco.ViewModel.Runtime"); sb.AppendLine("@using Eco.MVC"); sb.AppendLine("@using StreamingAppGenericAPIAndControllers"); sb.AppendLine("@model VMClass"); RazorControlRenderer razorRenderer = new RazorControlRenderer(); if (RenderSettings.CheckUseCSSGrid(viewModel)) { CSSGridViewUICreator cssGridViewCreator = new CSSGridViewUICreator(razorRenderer, sb); ViewModelRTCreator.CreateDataAndUI(null, cssGridViewCreator, viewModel); } else { BootstrapViewUICreator bootstrapViewCreator = new BootstrapViewUICreator(razorRenderer, sb); ViewModelRTCreator.CreateDataAndUI(null, bootstrapViewCreator, viewModel); // Create UI delegating work to UICreator } return sb.ToString(); } }

This page was edited 79 days ago on 02/10/2024. What links here