Browse files

Added overloads for Razor.Parse(), Razor.ParseMany() and Razor.Run() …

…to pass in DynamicViewBag contents.
  • Loading branch information...
1 parent 21368d5 commit 3ac2219227824153d149a0fc68bec3cb36a005aa @scottnickel committed Mar 13, 2012
View
176 nuget/lib/net40/RazorEngine.XML
@@ -427,15 +427,15 @@
</summary>
<param name="razorTemplate">The string template.</param>
<param name="model">The model instance or NULL if no model exists.</param>
- <param name="viewBag">The ViewBag initial contents or NULL for an initially empty ViewBag.</param>
+ <param name="viewBag">The ViewBag contents or NULL for an initially empty ViewBag.</param>
<param name="cacheName">The name of the template type in the cache or NULL if no caching is desired.</param>
<returns>The string result of the template.</returns>
</member>
<member name="M:RazorEngine.Templating.ITemplateService.ParseMany(System.Collections.Generic.IEnumerable{System.String},System.Collections.Generic.IEnumerable{System.Object},System.Collections.Generic.IEnumerable{RazorEngine.Templating.DynamicViewBag},System.Collections.Generic.IEnumerable{System.String},System.Boolean)">
<summary>
Parses the specified set of templates.
</summary>
- <param name="razorTemplates">The set of string templates to partse.</param>
+ <param name="razorTemplates">The set of string templates to parse.</param>
<param name="models">
The set of models or NULL if no models exist for all templates.
Individual elements in this set may be NULL if no model exists for a specific template.
@@ -473,7 +473,7 @@
Runs the specified template.
</summary>
<param name="template">The template to run.</param>
- <param name="viewBag">The ViewBag initial contents or NULL for an initially empty ViewBag.</param>
+ <param name="viewBag">The ViewBag contents or NULL for an initially empty ViewBag.</param>
<returns>The string result of the template.</returns>
</member>
<member name="P:RazorEngine.Templating.ITemplateService.EncodedStringFactory">
@@ -668,15 +668,15 @@
</summary>
<param name="razorTemplate">The string template.</param>
<param name="model">The model instance or NULL if no model exists.</param>
- <param name="viewBag">The ViewBag initial contents or NULL for an initially empty ViewBag.</param>
+ <param name="viewBag">The ViewBag contents or NULL for an initially empty ViewBag.</param>
<param name="cacheName">The name of the template type in the cache or NULL if no caching is desired.</param>
<returns>The string result of the template.</returns>
</member>
<member name="M:RazorEngine.Templating.IsolatedTemplateService.ParseMany(System.Collections.Generic.IEnumerable{System.String},System.Collections.Generic.IEnumerable{System.Object},System.Collections.Generic.IEnumerable{RazorEngine.Templating.DynamicViewBag},System.Collections.Generic.IEnumerable{System.String},System.Boolean)">
<summary>
Parses the specified set of templates.
</summary>
- <param name="razorTemplates">The set of string templates to partse.</param>
+ <param name="razorTemplates">The set of string templates to parse.</param>
<param name="models">
The set of models or NULL if no models exist for all templates.
Individual elements in this set may be NULL if no model exists for a specific template.
@@ -714,7 +714,7 @@
Runs the template with the specified name.
</summary>
<param name="template">The template to run.</param>
- <param name="viewBag">The ViewBag initial contents or NULL for an initially empty ViewBag.</param>
+ <param name="viewBag">The ViewBag contents or NULL for an initially empty ViewBag.</param>
<returns>The string result of the template.</returns>
</member>
<member name="P:RazorEngine.Templating.IsolatedTemplateService.RazorEngine#Templating#ITemplateService#EncodedStringFactory">
@@ -854,7 +854,7 @@
and if they do not exist, new types will be created and instantiated.
</summary>
<param name="razorTemplates">The set of templates to create.</param>
- <param name="names">The set of cache names.</param>
+ <param name="cacheNames">The set of cache names.</param>
<param name="parallel">Flag to determine whether to get the templates in parallel.</param>
<returns>The set of <see cref="T:RazorEngine.Templating.ITemplate"/> instances.</returns>
</member>
@@ -883,7 +883,7 @@
This method will provide a cache check to see if the compiled template type already exists and is valid.
</summary>
<param name="razorTemplate">The string template.</param>
- <param name="cacheName">The name of the cached template type.</param>
+ <param name="cacheName">The name of the template type in the cache or NULL if no caching is desired.</param>
<returns>The string result of the template.</returns>
</member>
<member name="M:RazorEngine.Razor.Parse(System.String,System.Object)">
@@ -910,7 +910,18 @@
<typeparam name="T">The model type.</typeparam>
<param name="razorTemplate">The string template.</param>
<param name="model">The model instance.</param>
- <param name="cacheName">The name of the template type in the cache.</param>
+ <param name="cacheName">The name of the template type in the cache or NULL if no caching is desired.</param>
+ <returns>The string result of the template.</returns>
+ </member>
+ <member name="M:RazorEngine.Razor.Parse``1(System.String,``0,RazorEngine.Templating.DynamicViewBag,System.String)">
+ <summary>
+ Parses and returns the result of the specified string template.
+ </summary>
+ <typeparam name="T">The model type.</typeparam>
+ <param name="razorTemplate">The string template.</param>
+ <param name="model">The model instance.</param>
+ <param name="viewBag">The ViewBag contents or NULL for an initially empty ViewBag.</param>
+ <param name="cacheName">The name of the template type in the cache or NULL if no caching is desired.</param>
<returns>The string result of the template.</returns>
</member>
<member name="M:RazorEngine.Razor.Parse(System.String,System.Object,System.String)">
@@ -919,23 +930,95 @@
</summary>
<param name="razorTemplate">The string template.</param>
<param name="model">The model instance.</param>
- <param name="cacheName">The name of the template type in the cache.</param>
+ <param name="cacheName">The name of the template type in the cache or NULL if no caching is desired.</param>
<returns>The string result of the template.</returns>
</member>
+ <member name="M:RazorEngine.Razor.Parse(System.String,System.Object,RazorEngine.Templating.DynamicViewBag,System.String)">
+ <summary>
+ Parses and returns the result of the specified string template.
+ </summary>
+ <param name="razorTemplate">The string template.</param>
+ <param name="model">The model instance.</param>
+ <param name="viewBag">The ViewBag contents or NULL for an initially empty ViewBag.</param>
+ <param name="cacheName">The name of the template type in the cache or NULL if no caching is desired.</param>
+ <returns>The string result of the template.</returns>
+ </member>
+ <member name="M:RazorEngine.Razor.ParseMany(System.String,System.Collections.Generic.IEnumerable{System.Object},System.Boolean)">
+ <summary>
+ Parses the template and merges with the many models provided.
+ </summary>
+ <param name="razorTemplate">The razor template.</param>
+ <param name="models">
+ The set of models (must contain at least one model).
+ </param>
+ <param name="parallel">Flag to determine whether parsing in parallel.</param>
+ <returns>The set of parsed template results.</returns>
+ </member>
<member name="M:RazorEngine.Razor.ParseMany(System.Collections.Generic.IEnumerable{System.String},System.Boolean)">
<summary>
Parses the specified set of templates.
</summary>
- <param name="razorTemplates">The set of string templates to partse.</param>
+ <param name="razorTemplates">The set of string templates to parse.</param>
+ <param name="parallel">Flag to determine whether parsing in templates.</param>
+ <returns>The set of parsed template results.</returns>
+ </member>
+ <member name="M:RazorEngine.Razor.ParseMany(System.Collections.Generic.IEnumerable{System.String},System.Collections.Generic.IEnumerable{System.Object},System.Boolean)">
+ <summary>
+ Parses the specified set of templates.
+ </summary>
+ <param name="razorTemplates">The set of string templates to parse.</param>
+ <param name="models">
+ The set of models or NULL if no models exist for all templates.
+ Individual elements in this set may be NULL if no model exists for a specific template.
+ </param>
<param name="parallel">Flag to determine whether parsing in templates.</param>
<returns>The set of parsed template results.</returns>
</member>
<member name="M:RazorEngine.Razor.ParseMany(System.Collections.Generic.IEnumerable{System.String},System.Collections.Generic.IEnumerable{System.String},System.Boolean)">
<summary>
Parses the specified set of templates.
</summary>
- <param name="razorTemplates">The set of string templates to partse.</param>
- <param name="cacheNames">The set of cache names.</param>
+ <param name="razorTemplates">The set of string templates to parse.</param>
+ <param name="cacheNames">
+ The set of cache names or NULL if no caching is desired for templates.
+ Individual elements in this set may be NULL if caching is not desired for a specific template.
+ </param>
+ <param name="parallel">Flag to determine whether parsing in templates.</param>
+ <returns>The set of parsed template results.</returns>
+ </member>
+ <member name="M:RazorEngine.Razor.ParseMany(System.Collections.Generic.IEnumerable{System.String},System.Collections.Generic.IEnumerable{System.Object},System.Collections.Generic.IEnumerable{System.String},System.Boolean)">
+ <summary>
+ Parses the specified set of templates.
+ </summary>
+ <param name="razorTemplates">The set of string templates to parse.</param>
+ <param name="models">
+ The set of models or NULL if no models exist for all templates.
+ Individual elements in this set may be NULL if no model exists for a specific template.
+ </param>
+ <param name="cacheNames">
+ The set of cache names or NULL if no caching is desired for templates.
+ Individual elements in this set may be NULL if caching is not desired for a specific template.
+ </param>
+ <param name="parallel">Flag to determine whether parsing in templates.</param>
+ <returns>The set of parsed template results.</returns>
+ </member>
+ <member name="M:RazorEngine.Razor.ParseMany(System.Collections.Generic.IEnumerable{System.String},System.Collections.Generic.IEnumerable{System.Object},System.Collections.Generic.IEnumerable{RazorEngine.Templating.DynamicViewBag},System.Collections.Generic.IEnumerable{System.String},System.Boolean)">
+ <summary>
+ Parses the specified set of templates.
+ </summary>
+ <param name="razorTemplates">The set of string templates to parse.</param>
+ <param name="models">
+ The set of models or NULL if no models exist for all templates.
+ Individual elements in this set may be NULL if no model exists for a specific template.
+ </param>
+ <param name="viewBags">
+ The set of initial ViewBag contents or NULL for an initially empty ViewBag for all templates.
+ Individual elements in this set may be NULL if an initially empty ViewBag is desired for a specific template.
+ </param>
+ <param name="cacheNames">
+ The set of cache names or NULL if no caching is desired for templates.
+ Individual elements in this set may be NULL if caching is not desired for a specific template.
+ </param>
<param name="parallel">Flag to determine whether parsing in templates.</param>
<returns>The set of parsed template results.</returns>
</member>
@@ -945,7 +1028,9 @@
</summary>
<typeparam name="T">The model type.</typeparam>
<param name="razorTemplate">The razor template.</param>
- <param name="models">The set of models.</param>
+ <param name="models">
+ The set of models (must contain at least one model).
+ </param>
<param name="parallel">Flag to determine whether parsing in parallel.</param>
<returns>The set of parsed template results.</returns>
</member>
@@ -954,8 +1039,11 @@
Parses the specified set of templates.
</summary>
<typeparam name="T">The model type.</typeparam>
- <param name="razorTemplates">The set of string templates to partse.</param>
- <param name="models">The set of models.</param>
+ <param name="razorTemplates">The set of string templates to parse.</param>
+ <param name="models">
+ The set of models or NULL if no models exist for all templates.
+ Individual elements in this set may be NULL if no model exists for a specific template.
+ </param>
<param name="parallel">Flag to determine whether parsing in templates.</param>
<returns>The set of parsed template results.</returns>
</member>
@@ -964,9 +1052,36 @@
Parses the specified set of templates.
</summary>
<typeparam name="T">The model type.</typeparam>
- <param name="razorTemplates">The set of string templates to partse.</param>
- <param name="models">The set of models.</param>
- <param name="names">The set of cache names.</param>
+ <param name="razorTemplates">The set of string templates to parse.</param>
+ <param name="models">
+ The set of models or NULL if no models exist for all templates.
+ Individual elements in this set may be NULL if no model exists for a specific template.
+ </param>
+ <param name="cacheNames">
+ The set of cache names or NULL if no caching is desired for templates.
+ Individual elements in this set may be NULL if caching is not desired for a specific template.
+ </param>
+ <param name="parallel">Flag to determine whether parsing in templates.</param>
+ <returns>The set of parsed template results.</returns>
+ </member>
+ <member name="M:RazorEngine.Razor.ParseMany``1(System.Collections.Generic.IEnumerable{System.String},System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEnumerable{RazorEngine.Templating.DynamicViewBag},System.Collections.Generic.IEnumerable{System.String},System.Boolean)">
+ <summary>
+ Parses the specified set of templates.
+ </summary>
+ <typeparam name="T">The model type.</typeparam>
+ <param name="razorTemplates">The set of string templates to parse.</param>
+ <param name="models">
+ The set of models or NULL if no models exist for all templates.
+ Individual elements in this set may be NULL if no model exists for a specific template.
+ </param>
+ <param name="viewBags">
+ The set of initial ViewBag contents or NULL for an initially empty ViewBag for all templates.
+ Individual elements in this set may be NULL if an initially empty ViewBag is desired for a specific template.
+ </param>
+ <param name="cacheNames">
+ The set of cache names or NULL if no caching is desired for templates.
+ Individual elements in this set may be NULL if caching is not desired for a specific template.
+ </param>
<param name="parallel">Flag to determine whether parsing in templates.</param>
<returns>The set of parsed template results.</returns>
</member>
@@ -1009,6 +1124,15 @@
<param name="model">The model.</param>
<returns>The string result of the template.</returns>
</member>
+ <member name="M:RazorEngine.Razor.Run(System.String,System.Object,RazorEngine.Templating.DynamicViewBag)">
+ <summary>
+ Runs the template with the specified name.
+ </summary>
+ <param name="cacheName">The name of the template type in cache.</param>
+ <param name="model">The model.</param>
+ <param name="viewBag">The ViewBag contents or NULL for an initially empty ViewBag.</param>
+ <returns>The string result of the template.</returns>
+ </member>
<member name="M:RazorEngine.Razor.Run``1(System.String,``0)">
<summary>
Runs the template with the specified name.
@@ -1018,6 +1142,16 @@
<param name="model">The model.</param>
<returns>The string result of the template.</returns>
</member>
+ <member name="M:RazorEngine.Razor.Run``1(System.String,``0,RazorEngine.Templating.DynamicViewBag)">
+ <summary>
+ Runs the template with the specified name.
+ </summary>
+ <typeparam name="T">The model type.</typeparam>
+ <param name="cacheName">The name of the template type in cache.</param>
+ <param name="model">The model.</param>
+ <param name="viewBag">The ViewBag contents or NULL for an initially empty ViewBag.</param>
+ <returns>The string result of the template.</returns>
+ </member>
<member name="M:RazorEngine.Razor.SetTemplateService(RazorEngine.Templating.ITemplateService)">
<summary>
Sets the template service.
@@ -2665,7 +2799,7 @@
</summary>
<param name="razorTemplate">The string template.</param>
<param name="model">The model instance or NULL if no model exists.</param>
- <param name="viewBag">The ViewBag initial contents or NULL for an initially empty ViewBag.</param>
+ <param name="viewBag">The ViewBag contents or NULL for an initially empty ViewBag.</param>
<param name="cacheName">The name of the template type in the cache or NULL if no caching is desired.</param>
<returns>The string result of the template.</returns>
</member>
@@ -2718,7 +2852,7 @@
Runs the specified template and returns the result.
</summary>
<param name="template">The template to run.</param>
- <param name="viewBag">The ViewBag initial contents or NULL for an initially empty ViewBag.</param>
+ <param name="viewBag">The ViewBag contents or NULL for an initially empty ViewBag.</param>
<returns>The string result of the template.</returns>
</member>
<member name="M:RazorEngine.Templating.TemplateService.SetModel``1(RazorEngine.Templating.ITemplate,``0)">
View
BIN nuget/lib/net40/RazorEngine.dll
Binary file not shown.
View
BIN nuget/lib/net40/RazorEngine.pdb
Binary file not shown.
View
214 src/Core/RazorEngine.Core/Razor.cs
@@ -192,13 +192,13 @@ public static ITemplate GetTemplate<T>(string razorTemplate, T model, string cac
/// and if they do not exist, new types will be created and instantiated.
/// </summary>
/// <param name="razorTemplates">The set of templates to create.</param>
- /// <param name="names">The set of cache names.</param>
+ /// <param name="cacheNames">The set of cache names.</param>
/// <param name="parallel">Flag to determine whether to get the templates in parallel.</param>
/// <returns>The set of <see cref="ITemplate"/> instances.</returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
- public static IEnumerable<ITemplate> GetTemplates(IEnumerable<string> razorTemplates, IEnumerable<string> names, bool parallel = false)
+ public static IEnumerable<ITemplate> GetTemplates(IEnumerable<string> razorTemplates, IEnumerable<string> cacheNames, bool parallel = false)
{
- return TemplateService.GetTemplates(razorTemplates, null, names, parallel);
+ return TemplateService.GetTemplates(razorTemplates, null, cacheNames, parallel);
}
/// <summary>
@@ -233,7 +233,7 @@ public static string Parse(string razorTemplate)
/// This method will provide a cache check to see if the compiled template type already exists and is valid.
/// </summary>
/// <param name="razorTemplate">The string template.</param>
- /// <param name="cacheName">The name of the cached template type.</param>
+ /// <param name="cacheName">The name of the template type in the cache or NULL if no caching is desired.</param>
/// <returns>The string result of the template.</returns>
public static string Parse(string razorTemplate, string cacheName)
{
@@ -269,7 +269,7 @@ public static string Parse<T>(string razorTemplate, T model)
/// <typeparam name="T">The model type.</typeparam>
/// <param name="razorTemplate">The string template.</param>
/// <param name="model">The model instance.</param>
- /// <param name="cacheName">The name of the template type in the cache.</param>
+ /// <param name="cacheName">The name of the template type in the cache or NULL if no caching is desired.</param>
/// <returns>The string result of the template.</returns>
public static string Parse<T>(string razorTemplate, T model, string cacheName)
{
@@ -279,19 +279,68 @@ public static string Parse<T>(string razorTemplate, T model, string cacheName)
/// <summary>
/// Parses and returns the result of the specified string template.
/// </summary>
+ /// <typeparam name="T">The model type.</typeparam>
/// <param name="razorTemplate">The string template.</param>
/// <param name="model">The model instance.</param>
- /// <param name="cacheName">The name of the template type in the cache.</param>
+ /// <param name="viewBag">The ViewBag contents or NULL for an initially empty ViewBag.</param>
+ /// <param name="cacheName">The name of the template type in the cache or NULL if no caching is desired.</param>
+ /// <returns>The string result of the template.</returns>
+ public static string Parse<T>(string razorTemplate, T model, DynamicViewBag viewBag, string cacheName)
+ {
+ return TemplateService.Parse(razorTemplate, model, viewBag, cacheName);
+ }
+
+ /// <summary>
+ /// Parses and returns the result of the specified string template.
+ /// </summary>
+ /// <param name="razorTemplate">The string template.</param>
+ /// <param name="model">The model instance.</param>
+ /// <param name="cacheName">The name of the template type in the cache or NULL if no caching is desired.</param>
/// <returns>The string result of the template.</returns>
public static string Parse(string razorTemplate, object model, string cacheName)
{
return TemplateService.Parse(razorTemplate, model, null, cacheName);
}
/// <summary>
+ /// Parses and returns the result of the specified string template.
+ /// </summary>
+ /// <param name="razorTemplate">The string template.</param>
+ /// <param name="model">The model instance.</param>
+ /// <param name="viewBag">The ViewBag contents or NULL for an initially empty ViewBag.</param>
+ /// <param name="cacheName">The name of the template type in the cache or NULL if no caching is desired.</param>
+ /// <returns>The string result of the template.</returns>
+ public static string Parse(string razorTemplate, object model, DynamicViewBag viewBag, string cacheName)
+ {
+ return TemplateService.Parse(razorTemplate, model, viewBag, cacheName);
+ }
+
+ /// <summary>
+ /// Parses the template and merges with the many models provided.
+ /// </summary>
+ /// <param name="razorTemplate">The razor template.</param>
+ /// <param name="models">
+ /// The set of models (must contain at least one model).
+ /// </param>
+ /// <param name="parallel">Flag to determine whether parsing in parallel.</param>
+ /// <returns>The set of parsed template results.</returns>
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
+ public static IEnumerable<string> ParseMany(string razorTemplate, IEnumerable<object> models, bool parallel = false)
+ {
+ if (models == null)
+ throw new ArgumentException("Expected models list (this parameter may not be NULL).");
+
+ if (models.Count() == 0)
+ throw new ArgumentException("Expected at least one entry in models list.");
+
+ List<string> razorTemplateList = Enumerable.Repeat(razorTemplate, models.Count()).ToList();
+ return TemplateService.ParseMany(razorTemplateList, models, null, null, parallel);
+ }
+
+ /// <summary>
/// Parses the specified set of templates.
/// </summary>
- /// <param name="razorTemplates">The set of string templates to partse.</param>
+ /// <param name="razorTemplates">The set of string templates to parse.</param>
/// <param name="parallel">Flag to determine whether parsing in templates.</param>
/// <returns>The set of parsed template results.</returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
@@ -303,8 +352,27 @@ public static IEnumerable<string> ParseMany(IEnumerable<string> razorTemplates,
/// <summary>
/// Parses the specified set of templates.
/// </summary>
- /// <param name="razorTemplates">The set of string templates to partse.</param>
- /// <param name="cacheNames">The set of cache names.</param>
+ /// <param name="razorTemplates">The set of string templates to parse.</param>
+ /// <param name="models">
+ /// The set of models or NULL if no models exist for all templates.
+ /// Individual elements in this set may be NULL if no model exists for a specific template.
+ /// </param>
+ /// <param name="parallel">Flag to determine whether parsing in templates.</param>
+ /// <returns>The set of parsed template results.</returns>
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
+ public static IEnumerable<string> ParseMany(IEnumerable<string> razorTemplates, IEnumerable<object> models, bool parallel = false)
+ {
+ return TemplateService.ParseMany(razorTemplates, models, null, null, parallel);
+ }
+
+ /// <summary>
+ /// Parses the specified set of templates.
+ /// </summary>
+ /// <param name="razorTemplates">The set of string templates to parse.</param>
+ /// <param name="cacheNames">
+ /// The set of cache names or NULL if no caching is desired for templates.
+ /// Individual elements in this set may be NULL if caching is not desired for a specific template.
+ /// </param>
/// <param name="parallel">Flag to determine whether parsing in templates.</param>
/// <returns>The set of parsed template results.</returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
@@ -314,16 +382,68 @@ public static IEnumerable<string> ParseMany(IEnumerable<string> razorTemplates,
}
/// <summary>
+ /// Parses the specified set of templates.
+ /// </summary>
+ /// <param name="razorTemplates">The set of string templates to parse.</param>
+ /// <param name="models">
+ /// The set of models or NULL if no models exist for all templates.
+ /// Individual elements in this set may be NULL if no model exists for a specific template.
+ /// </param>
+ /// <param name="cacheNames">
+ /// The set of cache names or NULL if no caching is desired for templates.
+ /// Individual elements in this set may be NULL if caching is not desired for a specific template.
+ /// </param>
+ /// <param name="parallel">Flag to determine whether parsing in templates.</param>
+ /// <returns>The set of parsed template results.</returns>
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
+ public static IEnumerable<string> ParseMany(IEnumerable<string> razorTemplates, IEnumerable<object> models, IEnumerable<string> cacheNames, bool parallel = false)
+ {
+ return TemplateService.ParseMany(razorTemplates, models, null, cacheNames, parallel);
+ }
+
+ /// <summary>
+ /// Parses the specified set of templates.
+ /// </summary>
+ /// <param name="razorTemplates">The set of string templates to parse.</param>
+ /// <param name="models">
+ /// The set of models or NULL if no models exist for all templates.
+ /// Individual elements in this set may be NULL if no model exists for a specific template.
+ /// </param>
+ /// <param name="viewBags">
+ /// The set of initial ViewBag contents or NULL for an initially empty ViewBag for all templates.
+ /// Individual elements in this set may be NULL if an initially empty ViewBag is desired for a specific template.
+ /// </param>
+ /// <param name="cacheNames">
+ /// The set of cache names or NULL if no caching is desired for templates.
+ /// Individual elements in this set may be NULL if caching is not desired for a specific template.
+ /// </param>
+ /// <param name="parallel">Flag to determine whether parsing in templates.</param>
+ /// <returns>The set of parsed template results.</returns>
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
+ public static IEnumerable<string> ParseMany(IEnumerable<string> razorTemplates, IEnumerable<object> models, IEnumerable<DynamicViewBag> viewBags, IEnumerable<string> cacheNames, bool parallel = false)
+ {
+ return TemplateService.ParseMany(razorTemplates, models, viewBags, cacheNames, parallel);
+ }
+
+ /// <summary>
/// Parses the template and merges with the many models provided.
/// </summary>
/// <typeparam name="T">The model type.</typeparam>
/// <param name="razorTemplate">The razor template.</param>
- /// <param name="models">The set of models.</param>
+ /// <param name="models">
+ /// The set of models (must contain at least one model).
+ /// </param>
/// <param name="parallel">Flag to determine whether parsing in parallel.</param>
/// <returns>The set of parsed template results.</returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
public static IEnumerable<string> ParseMany<T>(string razorTemplate, IEnumerable<T> models, bool parallel = false)
{
+ if (models == null)
+ throw new ArgumentException("Expected models list (this parameter may not be NULL).");
+
+ if (models.Count() == 0)
+ throw new ArgumentException("Expected at least one entry in models list.");
+
List<string> razorTemplateList = Enumerable.Repeat(razorTemplate, models.Count()).ToList();
List<object> modelList = (from m in models select (object)m).ToList();
return TemplateService.ParseMany(razorTemplateList, modelList, null, null, parallel);
@@ -333,8 +453,11 @@ public static IEnumerable<string> ParseMany<T>(string razorTemplate, IEnumerable
/// Parses the specified set of templates.
/// </summary>
/// <typeparam name="T">The model type.</typeparam>
- /// <param name="razorTemplates">The set of string templates to partse.</param>
- /// <param name="models">The set of models.</param>
+ /// <param name="razorTemplates">The set of string templates to parse.</param>
+ /// <param name="models">
+ /// The set of models or NULL if no models exist for all templates.
+ /// Individual elements in this set may be NULL if no model exists for a specific template.
+ /// </param>
/// <param name="parallel">Flag to determine whether parsing in templates.</param>
/// <returns>The set of parsed template results.</returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
@@ -348,16 +471,48 @@ public static IEnumerable<string> ParseMany<T>(IEnumerable<string> razorTemplate
/// Parses the specified set of templates.
/// </summary>
/// <typeparam name="T">The model type.</typeparam>
- /// <param name="razorTemplates">The set of string templates to partse.</param>
- /// <param name="models">The set of models.</param>
- /// <param name="names">The set of cache names.</param>
+ /// <param name="razorTemplates">The set of string templates to parse.</param>
+ /// <param name="models">
+ /// The set of models or NULL if no models exist for all templates.
+ /// Individual elements in this set may be NULL if no model exists for a specific template.
+ /// </param>
+ /// <param name="cacheNames">
+ /// The set of cache names or NULL if no caching is desired for templates.
+ /// Individual elements in this set may be NULL if caching is not desired for a specific template.
+ /// </param>
/// <param name="parallel">Flag to determine whether parsing in templates.</param>
/// <returns>The set of parsed template results.</returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
- public static IEnumerable<string> ParseMany<T>(IEnumerable<string> razorTemplates, IEnumerable<T> models, IEnumerable<string> names, bool parallel = false)
+ public static IEnumerable<string> ParseMany<T>(IEnumerable<string> razorTemplates, IEnumerable<T> models, IEnumerable<string> cacheNames, bool parallel = false)
{
List<object> modelList = (from m in models select (object)m).ToList();
- return TemplateService.ParseMany(razorTemplates, modelList, null, names, parallel);
+ return TemplateService.ParseMany(razorTemplates, modelList, null, cacheNames, parallel);
+ }
+
+ /// <summary>
+ /// Parses the specified set of templates.
+ /// </summary>
+ /// <typeparam name="T">The model type.</typeparam>
+ /// <param name="razorTemplates">The set of string templates to parse.</param>
+ /// <param name="models">
+ /// The set of models or NULL if no models exist for all templates.
+ /// Individual elements in this set may be NULL if no model exists for a specific template.
+ /// </param>
+ /// <param name="viewBags">
+ /// The set of initial ViewBag contents or NULL for an initially empty ViewBag for all templates.
+ /// Individual elements in this set may be NULL if an initially empty ViewBag is desired for a specific template.
+ /// </param>
+ /// <param name="cacheNames">
+ /// The set of cache names or NULL if no caching is desired for templates.
+ /// Individual elements in this set may be NULL if caching is not desired for a specific template.
+ /// </param>
+ /// <param name="parallel">Flag to determine whether parsing in templates.</param>
+ /// <returns>The set of parsed template results.</returns>
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
+ public static IEnumerable<string> ParseMany<T>(IEnumerable<string> razorTemplates, IEnumerable<T> models, IEnumerable<DynamicViewBag> viewBags, IEnumerable<string> cacheNames, bool parallel = false)
+ {
+ List<object> modelList = (from m in models select (object)m).ToList();
+ return TemplateService.ParseMany(razorTemplates, modelList, viewBags, cacheNames, parallel);
}
/// <summary>
@@ -417,6 +572,18 @@ public static string Run(string cacheName, object model)
/// <summary>
/// Runs the template with the specified name.
/// </summary>
+ /// <param name="cacheName">The name of the template type in cache.</param>
+ /// <param name="model">The model.</param>
+ /// <param name="viewBag">The ViewBag contents or NULL for an initially empty ViewBag.</param>
+ /// <returns>The string result of the template.</returns>
+ public static string Run(string cacheName, object model, DynamicViewBag viewBag)
+ {
+ return TemplateService.Run(cacheName, model, viewBag);
+ }
+
+ /// <summary>
+ /// Runs the template with the specified name.
+ /// </summary>
/// <typeparam name="T">The model type.</typeparam>
/// <param name="cacheName">The name of the template type in cache.</param>
/// <param name="model">The model.</param>
@@ -427,6 +594,19 @@ public static string Run<T>(string cacheName, T model)
}
/// <summary>
+ /// Runs the template with the specified name.
+ /// </summary>
+ /// <typeparam name="T">The model type.</typeparam>
+ /// <param name="cacheName">The name of the template type in cache.</param>
+ /// <param name="model">The model.</param>
+ /// <param name="viewBag">The ViewBag contents or NULL for an initially empty ViewBag.</param>
+ /// <returns>The string result of the template.</returns>
+ public static string Run<T>(string cacheName, T model, DynamicViewBag viewBag)
+ {
+ return TemplateService.Run(cacheName, model, viewBag);
+ }
+
+ /// <summary>
/// Sets the template service.
/// </summary>
/// <param name="service">The template service.</param>
View
6 src/Core/RazorEngine.Core/Templating/ITemplateService.cs
@@ -124,15 +124,15 @@ public interface ITemplateService : IDisposable
/// </summary>
/// <param name="razorTemplate">The string template.</param>
/// <param name="model">The model instance or NULL if no model exists.</param>
- /// <param name="viewBag">The ViewBag initial contents or NULL for an initially empty ViewBag.</param>
+ /// <param name="viewBag">The ViewBag contents or NULL for an initially empty ViewBag.</param>
/// <param name="cacheName">The name of the template type in the cache or NULL if no caching is desired.</param>
/// <returns>The string result of the template.</returns>
string Parse(string razorTemplate, object model, DynamicViewBag viewBag, string cacheName);
/// <summary>
/// Parses the specified set of templates.
/// </summary>
- /// <param name="razorTemplates">The set of string templates to partse.</param>
+ /// <param name="razorTemplates">The set of string templates to parse.</param>
/// <param name="models">
/// The set of models or NULL if no models exist for all templates.
/// Individual elements in this set may be NULL if no model exists for a specific template.
@@ -170,7 +170,7 @@ public interface ITemplateService : IDisposable
/// Runs the specified template.
/// </summary>
/// <param name="template">The template to run.</param>
- /// <param name="viewBag">The ViewBag initial contents or NULL for an initially empty ViewBag.</param>
+ /// <param name="viewBag">The ViewBag contents or NULL for an initially empty ViewBag.</param>
/// <returns>The string result of the template.</returns>
string Run(ITemplate template, DynamicViewBag viewBag);
View
6 src/Core/RazorEngine.Core/Templating/IsolatedTemplateService.cs
@@ -345,7 +345,7 @@ public bool HasTemplate(string cacheName)
/// </summary>
/// <param name="razorTemplate">The string template.</param>
/// <param name="model">The model instance or NULL if no model exists.</param>
- /// <param name="viewBag">The ViewBag initial contents or NULL for an initially empty ViewBag.</param>
+ /// <param name="viewBag">The ViewBag contents or NULL for an initially empty ViewBag.</param>
/// <param name="cacheName">The name of the template type in the cache or NULL if no caching is desired.</param>
/// <returns>The string result of the template.</returns>
public string Parse(string razorTemplate, object model, DynamicViewBag viewBag, string cacheName)
@@ -365,7 +365,7 @@ public string Parse(string razorTemplate, object model, DynamicViewBag viewBag,
/// <summary>
/// Parses the specified set of templates.
/// </summary>
- /// <param name="razorTemplates">The set of string templates to partse.</param>
+ /// <param name="razorTemplates">The set of string templates to parse.</param>
/// <param name="models">
/// The set of models or NULL if no models exist for all templates.
/// Individual elements in this set may be NULL if no model exists for a specific template.
@@ -433,7 +433,7 @@ public string Run(string cacheName, object model, DynamicViewBag viewBag)
/// Runs the template with the specified name.
/// </summary>
/// <param name="template">The template to run.</param>
- /// <param name="viewBag">The ViewBag initial contents or NULL for an initially empty ViewBag.</param>
+ /// <param name="viewBag">The ViewBag contents or NULL for an initially empty ViewBag.</param>
/// <returns>The string result of the template.</returns>
public string Run(ITemplate template, DynamicViewBag viewBag)
{
View
4 src/Core/RazorEngine.Core/Templating/TemplateService.cs
@@ -408,7 +408,7 @@ public virtual IEnumerable<ITemplate> GetTemplates(IEnumerable<string> razorTemp
/// </summary>
/// <param name="razorTemplate">The string template.</param>
/// <param name="model">The model instance or NULL if no model exists.</param>
- /// <param name="viewBag">The ViewBag initial contents or NULL for an initially empty ViewBag.</param>
+ /// <param name="viewBag">The ViewBag contents or NULL for an initially empty ViewBag.</param>
/// <param name="cacheName">The name of the template type in the cache or NULL if no caching is desired.</param>
/// <returns>The string result of the template.</returns>
[Pure]
@@ -549,7 +549,7 @@ public string Run(string cacheName, object model, DynamicViewBag viewBag)
/// Runs the specified template and returns the result.
/// </summary>
/// <param name="template">The template to run.</param>
- /// <param name="viewBag">The ViewBag initial contents or NULL for an initially empty ViewBag.</param>
+ /// <param name="viewBag">The ViewBag contents or NULL for an initially empty ViewBag.</param>
/// <returns>The string result of the template.</returns>
public string Run(ITemplate template, DynamicViewBag viewBag)
{

0 comments on commit 3ac2219

Please sign in to comment.