Skip to content

Commit cb14516

Browse files
committed
DocComments
1 parent b10b5dc commit cb14516

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

ViewEngine.Core/CompiledHandlebarsViewEngine.cs

+17-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ public CompiledHandlebarsViewEngine(Assembly assembly, CompiledHandlebarsViewEng
2222
{
2323
_options = options;
2424

25-
//This part is close to magic.
2625
//The basic idea: Search through the assembly, find all compiled HandlebarsTemplates and create Func<>-objects for their render methods.
2726
//Wrap these Func<>-objects in a generic class and store it in a Dictionary to be able to access them at runtime
2827
//Then the View can call the wrapped Func<>-object without knowing the actual type of the viewModel and without using reflection!
@@ -64,6 +63,15 @@ private string GetVirtualPath(Assembly assembly, Type template)
6463
}
6564
}
6665

66+
/// <summary>
67+
/// Tries to find a View by name and context (controller and area name)
68+
/// It uses the viewlocation formats passed in the options to generate possible locations and then looks in the mapping if they exist
69+
/// First match wins!
70+
/// </summary>
71+
/// <param name="context"></param>
72+
/// <param name="viewName"></param>
73+
/// <param name="isMainPage"></param>
74+
/// <returns></returns>
6775
public ViewEngineResult FindView(ActionContext context, string viewName, bool isMainPage)
6876
{
6977
var controllerName = RazorViewEngine.GetNormalizedRouteValue(context, ControllerKey);
@@ -78,6 +86,14 @@ public ViewEngineResult FindView(ActionContext context, string viewName, bool is
7886
}
7987
}
8088

89+
/// <summary>
90+
/// Tries to find a View by its ViewPath.
91+
/// Checks if the ViewPath exists in the mappings and then returns the View
92+
/// </summary>
93+
/// <param name="executingFilePath"></param>
94+
/// <param name="viewPath"></param>
95+
/// <param name="isMainPage"></param>
96+
/// <returns></returns>
8197
public ViewEngineResult GetView(string executingFilePath, string viewPath, bool isMainPage)
8298
{
8399
if (_mappings.ContainsKey(viewPath.ToLower()))

ViewEngine.Core/CompiledHandlebarsViewEngineOptions.cs

+15
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,24 @@ namespace CompiledHandlebars.ViewEngine.Core
66
{
77
public class CompiledHandlebarsViewEngineOptions
88
{
9+
/// <summary>
10+
/// Possible locations for views.
11+
/// Format strings may contain the ViewName '{0}' and the ControllerName '{1}'
12+
/// </summary>
913
public IList<string> ViewLocationFormats { get; set; } = new List<string>();
14+
/// <summary>
15+
/// Possible locations for view
16+
/// Format strings may contain the ViewName '{0}', the ControllerName '{1}' and the AreaName '{2}'
17+
/// </summary>
1018
public IList<string> AreaViewLocationFormats { get; set; } = new List<string>();
1119

20+
/// <summary>
21+
/// Generate all possible view locations from the ViewLocationFormats and the passed parameters
22+
/// </summary>
23+
/// <param name="action"></param>
24+
/// <param name="controller"></param>
25+
/// <param name="area"></param>
26+
/// <returns></returns>
1227
public IEnumerable<string> PossibleVariants(string action, string controller, string area = null)
1328
{
1429
if (area!=null)

0 commit comments

Comments
 (0)