forked from pauldotknopf/JavaScriptViewEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIRenderEngine.cs
More file actions
80 lines (74 loc) · 2.44 KB
/
IRenderEngine.cs
File metadata and controls
80 lines (74 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using System;
using System.Threading.Tasks;
#if DOTNETCORE
using Microsoft.AspNetCore.Routing;
#else
using System.Web.Routing;
#endif
using Newtonsoft.Json;
namespace JavaScriptViewEngine
{
/// <summary>
/// An abstracted render engine
/// </summary>
public interface IRenderEngine : IDisposable
{
/// <summary>
/// Perform a render
/// </summary>
/// <param name="path">The path.</param>
/// <param name="model">The model.</param>
/// <param name="viewBag">The view bag.</param>
/// <param name="routeValues">The route values.</param>
/// <param name="area">The area.</param>
/// <param name="viewType">Type of the view.</param>
/// <returns></returns>
Task<RenderResult> RenderAsync(string path, object model, dynamic viewBag, RouteValueDictionary routeValues, string area, ViewType viewType);
/// <summary>
/// Perform a render
/// </summary>
/// <param name="path">The path.</param>
/// <param name="model">The model.</param>
/// <param name="viewBag">The view bag.</param>
/// <param name="routeValues">The route values.</param>
/// <param name="area">The area.</param>
/// <param name="viewType">Type of the view.</param>
/// <returns></returns>
RenderResult Render(string path, object model, dynamic viewBag, RouteValueDictionary routeValues, string area, ViewType viewType);
}
/// <summary>
/// The type of full being rendered
/// </summary>
public enum ViewType
{
/// <summary>
/// Full request, including "<html></html>"
/// </summary>
Full,
/// <summary>
/// A small chunk of html
/// </summary>
Partial
}
/// <summary>
/// The render result of a <see cref="IRenderEngine"/>
/// </summary>
public class RenderResult
{
/// <summary>
/// The html
/// </summary>
[JsonProperty("html")]
public string Html { get; set; }
/// <summary>
/// The response status code. Only used if the ViewType = Full
/// </summary>
[JsonProperty("status")]
public int Status { get; set; }
/// <summary>
/// Did the JavaScript engine ask us to redirect the user to another location?
/// </summary>
[JsonProperty("redirect")]
public string Redirect { get; set; }
}
}