/// <summary>
 /// Creates a <see cref="HtmlBuilderRendererResult{TModel}"/>
 /// </summary>
 /// <param name="view">The view</param>
 /// <param name="model">The model</param>
 /// <param name="statusCode">A custom status code</param>
 public HtmlBuilderRendererResult(IHtmlBuilderRenderer <TModel> view, TModel model, HttpStatusCode?statusCode = null)
 {
     if (view == null)
     {
         throw new ArgumentNullException(nameof(view));
     }
     View       = view;
     Model      = model;
     StatusCode = statusCode;
 }
 /// <summary>
 /// Creates an <see cref="IActionResult"/> from an <see cref="IHtmlBuilderRenderer{TModel}"/> and a <typeparamref name="TModel"/>
 /// </summary>
 /// <typeparam name="TModel">The model type</typeparam>
 /// <param name="view">The view</param>
 /// <param name="model">The model</param>
 /// <param name="statusCode">A custom status code</param>
 /// <returns>An <see cref="IActionResult"/></returns>
 public static HtmlBuilderRendererResult <TModel> Create <TModel>(
     IHtmlBuilderRenderer <TModel> view,
     TModel model,
     HttpStatusCode?statusCode = null
     )
 {
     if (view == null)
     {
         throw new ArgumentNullException(nameof(view));
     }
     return(new HtmlBuilderRendererResult <TModel>(view, model, statusCode));
 }
Exemplo n.º 3
0
 /// <summary>
 /// Creates a <see cref="TwentyViewAdapter{TModel}"/>
 /// </summary>
 /// <param name="path">The view path</param>
 /// <param name="view">The view</param>
 public TwentyViewAdapter(string path, IHtmlBuilderRenderer <TModel> view)
 {
     if (path == null)
     {
         throw new ArgumentNullException(nameof(path));
     }
     if (view == null)
     {
         throw new ArgumentNullException(nameof(view));
     }
     Path  = path;
     _view = view;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Add an <see cref="IHtmlBuilderRenderer{TModel}"/> to the collection
        /// </summary>
        /// <param name="path">The view path</param>
        /// <param name="view">The view</param>
        public void RegisterSingleton <TModel>(string path, IHtmlBuilderRenderer <TModel> view)
        {
            var adapter = new TwentyViewAdapter <TModel>(path, view);

            Views[path] = adapter;
        }
Exemplo n.º 5
0
 /// <summary>
 /// Add an <see cref="IHtmlBuilderRenderer{TModel}"/> to the collection
 /// </summary>
 /// <param name="controllerName">The controller name</param>
 /// <param name="viewName">The view name</param>
 /// <param name="view">The view</param>
 public void RegisterSingleton <TModel>(string controllerName, string viewName, IHtmlBuilderRenderer <TModel> view)
 {
     RegisterSingleton(controllerName + "/" + viewName, view);
 }
 /// <summary>
 /// Creates an <see cref="IActionResult"/> from an <see cref="IHtmlBuilderRenderer{TModel}"/> and a <typeparamref name="TModel"/>
 /// </summary>
 /// <typeparam name="TModel">The model type</typeparam>
 /// <param name="view">The view</param>
 /// <param name="model">The model</param>
 /// <param name="statusCode">A custom status code</param>
 /// <returns>An <see cref="IActionResult"/></returns>
 public static HtmlBuilderRendererResult <TModel> ToActionResult <TModel>(
     this IHtmlBuilderRenderer <TModel> view,
     TModel model,
     HttpStatusCode?statusCode = null
     ) => Create(view, model, statusCode);