/// <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)); }
/// <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; }
/// <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; }
/// <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);