Cleanup Display, Partial, and Validation extensions
- correct file and class names for some HH extensions - three class names were correct but didn't match containing file - three class and file names matched but didn't start with HtmlHelper - clean up trailing whitespace and long lines in changed Extensions.cs files - `HtmlHelperPartialAsyncExtensions`, `HtmlHelperRenderPartialAsyncExtensions` and `HtmlHelperValidationExtensions` lacked some `[NotNull]` attributes - merge extension files by concept - Display / DisplayFor / DisplayForModel methods all into `HtmlHelperDisplayExtensions` - Partial / RenderPartial methods all into `HtmlHelperPartialExtensions` - use `IHtmlHelper<TModel>` everywhere
This commit is contained in:
parent
d2453c5832
commit
ba08f8e8d8
|
|
@ -60,8 +60,5 @@
|
||||||
<Compile Include="Startup.cs" />
|
<Compile Include="Startup.cs" />
|
||||||
<Compile Include="ViewMetadata.cs" />
|
<Compile Include="ViewMetadata.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="Properties\" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VSToolsPath)\ProjectK\Microsoft.Web.ProjectK.targets" Condition="'$(VSToolsPath)' != ''" />
|
<Import Project="$(VSToolsPath)\ProjectK\Microsoft.Web.ProjectK.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -23,8 +23,5 @@
|
||||||
<Compile Include="NotNullArgument.cs" />
|
<Compile Include="NotNullArgument.cs" />
|
||||||
<Compile Include="TypeExtensions.cs" />
|
<Compile Include="TypeExtensions.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="Properties\" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VSToolsPath)\ProjectK\Microsoft.Web.ProjectK.targets" Condition="'$(VSToolsPath)' != ''" />
|
<Import Project="$(VSToolsPath)\ProjectK\Microsoft.Web.ProjectK.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -125,9 +125,6 @@
|
||||||
<Compile Include="ReflectedActionExecutor.cs" />
|
<Compile Include="ReflectedActionExecutor.cs" />
|
||||||
<Compile Include="ReflectedActionInvoker.cs" />
|
<Compile Include="ReflectedActionInvoker.cs" />
|
||||||
<Compile Include="ReflectedActionInvokerProvider.cs" />
|
<Compile Include="ReflectedActionInvokerProvider.cs" />
|
||||||
<Compile Include="Rendering\DisplayExtensions.cs" />
|
|
||||||
<Compile Include="Rendering\DisplayForExtensions.cs" />
|
|
||||||
<Compile Include="Rendering\DisplayForModelExtensions.cs" />
|
|
||||||
<Compile Include="Rendering\DynamicViewData.cs" />
|
<Compile Include="Rendering\DynamicViewData.cs" />
|
||||||
<Compile Include="Rendering\Expressions\CachedExpressionCompiler.cs" />
|
<Compile Include="Rendering\Expressions\CachedExpressionCompiler.cs" />
|
||||||
<Compile Include="Rendering\Expressions\ExpressionHelper.cs" />
|
<Compile Include="Rendering\Expressions\ExpressionHelper.cs" />
|
||||||
|
|
@ -138,10 +135,13 @@
|
||||||
<Compile Include="Rendering\Expressions\ViewDataInfo.cs" />
|
<Compile Include="Rendering\Expressions\ViewDataInfo.cs" />
|
||||||
<Compile Include="Rendering\FormMethod.cs" />
|
<Compile Include="Rendering\FormMethod.cs" />
|
||||||
<Compile Include="Rendering\HtmlAttributePropertyHelper.cs" />
|
<Compile Include="Rendering\HtmlAttributePropertyHelper.cs" />
|
||||||
|
<Compile Include="Rendering\HtmlHelperDisplayExtensions.cs" />
|
||||||
<Compile Include="Rendering\HtmlHelperFormExtensions.cs" />
|
<Compile Include="Rendering\HtmlHelperFormExtensions.cs" />
|
||||||
<Compile Include="Rendering\HtmlHelperInputExtensions.cs" />
|
<Compile Include="Rendering\HtmlHelperInputExtensions.cs" />
|
||||||
<Compile Include="Rendering\HtmlHelperLinkExtensions.cs" />
|
<Compile Include="Rendering\HtmlHelperLinkExtensions.cs" />
|
||||||
<Compile Include="Rendering\HtmlHelperNameExtensions.cs" />
|
<Compile Include="Rendering\HtmlHelperNameExtensions.cs" />
|
||||||
|
<Compile Include="Rendering\HtmlHelperPartialExtensions.cs" />
|
||||||
|
<Compile Include="Rendering\HtmlHelperValidationExtensions.cs" />
|
||||||
<Compile Include="Rendering\HtmlHelperValueExtensions.cs" />
|
<Compile Include="Rendering\HtmlHelperValueExtensions.cs" />
|
||||||
<Compile Include="Rendering\HtmlString.cs" />
|
<Compile Include="Rendering\HtmlString.cs" />
|
||||||
<Compile Include="Rendering\Html\HtmlHelper.cs" />
|
<Compile Include="Rendering\Html\HtmlHelper.cs" />
|
||||||
|
|
@ -157,9 +157,6 @@
|
||||||
<Compile Include="Rendering\IView.cs" />
|
<Compile Include="Rendering\IView.cs" />
|
||||||
<Compile Include="Rendering\IViewEngine.cs" />
|
<Compile Include="Rendering\IViewEngine.cs" />
|
||||||
<Compile Include="Rendering\MvcForm.cs" />
|
<Compile Include="Rendering\MvcForm.cs" />
|
||||||
<Compile Include="Rendering\PartialAsyncExtensions.cs" />
|
|
||||||
<Compile Include="Rendering\RenderPartialAsyncExtensions.cs" />
|
|
||||||
<Compile Include="Rendering\ValidationExtensions.cs" />
|
|
||||||
<Compile Include="Rendering\ViewEngineResult.cs" />
|
<Compile Include="Rendering\ViewEngineResult.cs" />
|
||||||
<Compile Include="RouteConstraintAttribute.cs" />
|
<Compile Include="RouteConstraintAttribute.cs" />
|
||||||
<Compile Include="RouteDataActionConstraint.cs" />
|
<Compile Include="RouteDataActionConstraint.cs" />
|
||||||
|
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.Rendering
|
|
||||||
{
|
|
||||||
public static class HtmlHelperDisplayExtensions
|
|
||||||
{
|
|
||||||
public static HtmlString Display<TModel>([NotNull] this IHtmlHelper<TModel> html,
|
|
||||||
string expression)
|
|
||||||
{
|
|
||||||
return html.Display(expression, templateName: null, htmlFieldName: null, additionalViewData: null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HtmlString Display<TModel>([NotNull] this IHtmlHelper<TModel> html,
|
|
||||||
string expression,
|
|
||||||
object additionalViewData)
|
|
||||||
{
|
|
||||||
return html.Display(expression, templateName: null, htmlFieldName: null, additionalViewData: additionalViewData);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HtmlString Display<TModel>([NotNull] this IHtmlHelper<TModel> html,
|
|
||||||
string expression,
|
|
||||||
string templateName)
|
|
||||||
{
|
|
||||||
return html.Display(expression, templateName, htmlFieldName: null, additionalViewData: null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HtmlString Display<TModel>([NotNull] this IHtmlHelper<TModel> html,
|
|
||||||
string expression,
|
|
||||||
string templateName,
|
|
||||||
object additionalViewData)
|
|
||||||
{
|
|
||||||
return html.Display(expression, templateName, htmlFieldName: null, additionalViewData: additionalViewData);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HtmlString Display<TModel>([NotNull] this IHtmlHelper<TModel> html,
|
|
||||||
string expression,
|
|
||||||
string templateName,
|
|
||||||
string htmlFieldName)
|
|
||||||
{
|
|
||||||
return html.Display(expression, templateName, htmlFieldName, additionalViewData: null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,45 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Diagnostics.CodeAnalysis;
|
|
||||||
using System.Linq.Expressions;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.Rendering
|
|
||||||
{
|
|
||||||
public static class HtmlHelperDisplayForExtensions
|
|
||||||
{
|
|
||||||
public static HtmlString DisplayFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html,
|
|
||||||
[NotNull] Expression<Func<TModel, TValue>> expression)
|
|
||||||
{
|
|
||||||
return html.DisplayFor<TValue>(expression, templateName: null, htmlFieldName: null, additionalViewData: null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HtmlString DisplayFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html,
|
|
||||||
[NotNull] Expression<Func<TModel, TValue>> expression,
|
|
||||||
object additionalViewData)
|
|
||||||
{
|
|
||||||
return html.DisplayFor<TValue>(expression, templateName: null, htmlFieldName: null, additionalViewData: additionalViewData);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HtmlString DisplayFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html,
|
|
||||||
[NotNull] Expression<Func<TModel, TValue>> expression,
|
|
||||||
string templateName)
|
|
||||||
{
|
|
||||||
return html.DisplayFor<TValue>(expression, templateName, htmlFieldName: null, additionalViewData: null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HtmlString DisplayFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html,
|
|
||||||
[NotNull] Expression<Func<TModel, TValue>> expression,
|
|
||||||
string templateName,
|
|
||||||
object additionalViewData)
|
|
||||||
{
|
|
||||||
return html.DisplayFor<TValue>(expression, templateName, htmlFieldName: null, additionalViewData: additionalViewData);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HtmlString DisplayFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html,
|
|
||||||
[NotNull] Expression<Func<TModel, TValue>> expression,
|
|
||||||
string templateName,
|
|
||||||
string htmlFieldName)
|
|
||||||
{
|
|
||||||
return html.DisplayFor<TValue>(expression, templateName: templateName, htmlFieldName: htmlFieldName, additionalViewData: null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.Rendering
|
|
||||||
{
|
|
||||||
public static class HtmlHelperDisplayForModelExtensions
|
|
||||||
{
|
|
||||||
public static HtmlString DisplayForModel<TModel>([NotNull] this IHtmlHelper<TModel> html)
|
|
||||||
{
|
|
||||||
return html.DisplayForModel(templateName: null, htmlFieldName: null, additionalViewData: null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HtmlString DisplayForModel<TModel>([NotNull] this IHtmlHelper<TModel> html,
|
|
||||||
object additionalViewData)
|
|
||||||
{
|
|
||||||
return html.DisplayForModel(templateName: null, htmlFieldName: null, additionalViewData: additionalViewData);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HtmlString DisplayForModel<TModel>([NotNull] this IHtmlHelper<TModel> html,
|
|
||||||
string templateName)
|
|
||||||
{
|
|
||||||
return html.DisplayForModel(templateName, htmlFieldName: null, additionalViewData: null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HtmlString DisplayForModel<TModel>([NotNull] this IHtmlHelper<TModel> html,
|
|
||||||
string templateName,
|
|
||||||
object additionalViewData)
|
|
||||||
{
|
|
||||||
return html.DisplayForModel(templateName, htmlFieldName: null, additionalViewData: additionalViewData);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HtmlString DisplayForModel<TModel>([NotNull] this IHtmlHelper<TModel> html,
|
|
||||||
string templateName,
|
|
||||||
string htmlFieldName)
|
|
||||||
{
|
|
||||||
return html.DisplayForModel(templateName, htmlFieldName, additionalViewData: null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,117 @@
|
||||||
|
using System;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
|
{
|
||||||
|
public static class HtmlHelperDisplayExtensions
|
||||||
|
{
|
||||||
|
public static HtmlString Display<TModel>([NotNull] this IHtmlHelper<TModel> html,
|
||||||
|
string expression)
|
||||||
|
{
|
||||||
|
return html.Display(expression, templateName: null, htmlFieldName: null, additionalViewData: null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HtmlString Display<TModel>([NotNull] this IHtmlHelper<TModel> html,
|
||||||
|
string expression,
|
||||||
|
object additionalViewData)
|
||||||
|
{
|
||||||
|
return html.Display(expression, templateName: null, htmlFieldName: null,
|
||||||
|
additionalViewData: additionalViewData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HtmlString Display<TModel>([NotNull] this IHtmlHelper<TModel> html,
|
||||||
|
string expression,
|
||||||
|
string templateName)
|
||||||
|
{
|
||||||
|
return html.Display(expression, templateName, htmlFieldName: null, additionalViewData: null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HtmlString Display<TModel>([NotNull] this IHtmlHelper<TModel> html,
|
||||||
|
string expression,
|
||||||
|
string templateName,
|
||||||
|
object additionalViewData)
|
||||||
|
{
|
||||||
|
return html.Display(expression, templateName, htmlFieldName: null, additionalViewData: additionalViewData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HtmlString Display<TModel>([NotNull] this IHtmlHelper<TModel> html,
|
||||||
|
string expression,
|
||||||
|
string templateName,
|
||||||
|
string htmlFieldName)
|
||||||
|
{
|
||||||
|
return html.Display(expression, templateName, htmlFieldName, additionalViewData: null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HtmlString DisplayFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html,
|
||||||
|
[NotNull] Expression<Func<TModel, TValue>> expression)
|
||||||
|
{
|
||||||
|
return html.DisplayFor<TValue>(expression, templateName: null, htmlFieldName: null,
|
||||||
|
additionalViewData: null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HtmlString DisplayFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html,
|
||||||
|
[NotNull] Expression<Func<TModel, TValue>> expression,
|
||||||
|
object additionalViewData)
|
||||||
|
{
|
||||||
|
return html.DisplayFor<TValue>(expression, templateName: null, htmlFieldName: null,
|
||||||
|
additionalViewData: additionalViewData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HtmlString DisplayFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html,
|
||||||
|
[NotNull] Expression<Func<TModel, TValue>> expression,
|
||||||
|
string templateName)
|
||||||
|
{
|
||||||
|
return html.DisplayFor<TValue>(expression, templateName, htmlFieldName: null, additionalViewData: null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HtmlString DisplayFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html,
|
||||||
|
[NotNull] Expression<Func<TModel, TValue>> expression,
|
||||||
|
string templateName,
|
||||||
|
object additionalViewData)
|
||||||
|
{
|
||||||
|
return html.DisplayFor<TValue>(expression, templateName, htmlFieldName: null,
|
||||||
|
additionalViewData: additionalViewData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HtmlString DisplayFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html,
|
||||||
|
[NotNull] Expression<Func<TModel, TValue>> expression,
|
||||||
|
string templateName,
|
||||||
|
string htmlFieldName)
|
||||||
|
{
|
||||||
|
return html.DisplayFor<TValue>(expression, templateName: templateName, htmlFieldName: htmlFieldName,
|
||||||
|
additionalViewData: null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HtmlString DisplayForModel<TModel>([NotNull] this IHtmlHelper<TModel> html)
|
||||||
|
{
|
||||||
|
return html.DisplayForModel(templateName: null, htmlFieldName: null, additionalViewData: null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HtmlString DisplayForModel<TModel>([NotNull] this IHtmlHelper<TModel> html,
|
||||||
|
object additionalViewData)
|
||||||
|
{
|
||||||
|
return html.DisplayForModel(templateName: null, htmlFieldName: null,
|
||||||
|
additionalViewData: additionalViewData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HtmlString DisplayForModel<TModel>([NotNull] this IHtmlHelper<TModel> html,
|
||||||
|
string templateName)
|
||||||
|
{
|
||||||
|
return html.DisplayForModel(templateName, htmlFieldName: null, additionalViewData: null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HtmlString DisplayForModel<TModel>([NotNull] this IHtmlHelper<TModel> html,
|
||||||
|
string templateName,
|
||||||
|
object additionalViewData)
|
||||||
|
{
|
||||||
|
return html.DisplayForModel(templateName, htmlFieldName: null, additionalViewData: additionalViewData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HtmlString DisplayForModel<TModel>([NotNull] this IHtmlHelper<TModel> html,
|
||||||
|
string templateName,
|
||||||
|
string htmlFieldName)
|
||||||
|
{
|
||||||
|
return html.DisplayForModel(templateName, htmlFieldName, additionalViewData: null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,100 @@
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
|
{
|
||||||
|
public static class HtmlHelperPartialExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Renders the partial view with the parent's view data and model to a string.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The <see cref="Type"/> of the model.</typeparam>
|
||||||
|
/// <param name="htmlHelper">The <see cref="HtmlHelper"/> instance that this method extends.</param>
|
||||||
|
/// <param name="partialViewName">The name of the partial view to render.</param>
|
||||||
|
/// <returns>
|
||||||
|
/// A <see cref="Task{T}"/> that represents when rendering to the <see cref="HtmlString"/> has completed.
|
||||||
|
/// </returns>
|
||||||
|
public static Task<HtmlString> PartialAsync<TModel>([NotNull] this IHtmlHelper<TModel> htmlHelper,
|
||||||
|
[NotNull] string partialViewName)
|
||||||
|
{
|
||||||
|
return htmlHelper.PartialAsync(partialViewName, htmlHelper.ViewData.Model, viewData: null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Renders the partial view with the given view data and, implicitly, the given view data's model to a string.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The <see cref="Type"/> of the model.</typeparam>
|
||||||
|
/// <param name="htmlHelper">The <see cref="HtmlHelper"/> instance that this method extends.</param>
|
||||||
|
/// <param name="partialViewName">The name of the partial view to render.</param>
|
||||||
|
/// <param name="viewData">
|
||||||
|
/// The <see cref="ViewDataDictionary"/> that is provided to the partial view that will be rendered.
|
||||||
|
/// </param>
|
||||||
|
/// <returns>
|
||||||
|
/// A <see cref="Task{T}"/> that represents when rendering to the <see cref="HtmlString"/> has completed.
|
||||||
|
/// </returns>
|
||||||
|
public static Task<HtmlString> PartialAsync<TModel>([NotNull] this IHtmlHelper<TModel> htmlHelper,
|
||||||
|
[NotNull] string partialViewName, ViewDataDictionary viewData)
|
||||||
|
{
|
||||||
|
return htmlHelper.PartialAsync(partialViewName, htmlHelper.ViewData.Model, viewData: viewData);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Renders the partial view with an empty view data and the given model to a string.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The <see cref="Type"/> of the model.</typeparam>
|
||||||
|
/// <param name="htmlHelper">The <see cref="HtmlHelper"/> instance that this method extends.</param>
|
||||||
|
/// <param name="partialViewName">The name of the partial view to render.</param>
|
||||||
|
/// <param name="model">The model to provide to the partial view that will be rendered.</param>
|
||||||
|
/// <returns>
|
||||||
|
/// A <see cref="Task{T}"/> that represents when rendering to the <see cref="HtmlString"/> has completed.
|
||||||
|
/// </returns>
|
||||||
|
public static Task<HtmlString> PartialAsync<TModel>([NotNull] this IHtmlHelper<TModel> htmlHelper,
|
||||||
|
[NotNull] string partialViewName, object model)
|
||||||
|
{
|
||||||
|
return htmlHelper.PartialAsync(partialViewName, model, viewData: null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Renders the partial view with the parent's view data and model.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The <see cref="Type"/> of the model.</typeparam>
|
||||||
|
/// <param name="htmlHelper">The <see cref="HtmlHelper"/> instance that this method extends.</param>
|
||||||
|
/// <param name="partialViewName">The name of the partial view to render.</param>
|
||||||
|
/// <returns>A <see cref="Task"/> that represents when rendering has completed.</returns>
|
||||||
|
public static Task RenderPartialAsync<TModel>([NotNull] this IHtmlHelper<TModel> htmlHelper,
|
||||||
|
[NotNull] string partialViewName)
|
||||||
|
{
|
||||||
|
return htmlHelper.RenderPartialAsync(partialViewName, htmlHelper.ViewData.Model,
|
||||||
|
viewData: htmlHelper.ViewData);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Renders the partial view with the given view data and, implicitly, the given view data's model.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The <see cref="Type"/> of the model.</typeparam>
|
||||||
|
/// <param name="htmlHelper">The <see cref="HtmlHelper"/> instance that this method extends.</param>
|
||||||
|
/// <param name="partialViewName">The name of the partial view to render.</param>
|
||||||
|
/// <param name="viewData">
|
||||||
|
/// The <see cref="ViewDataDictionary"/> that is provided to the partial view that will be rendered.
|
||||||
|
/// </param>
|
||||||
|
/// <returns>A <see cref="Task"/> that represents when rendering has completed.</returns>
|
||||||
|
public static Task RenderPartialAsync<TModel>([NotNull] this IHtmlHelper<TModel> htmlHelper,
|
||||||
|
[NotNull] string partialViewName, ViewDataDictionary viewData)
|
||||||
|
{
|
||||||
|
return htmlHelper.RenderPartialAsync(partialViewName, htmlHelper.ViewData.Model, viewData: viewData);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Renders the partial view with an empty view data and the given model.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The <see cref="Type"/> of the model.</typeparam>
|
||||||
|
/// <param name="htmlHelper">The <see cref="HtmlHelper"/> instance that this method extends.</param>
|
||||||
|
/// <param name="partialViewName">The name of the partial view to render.</param>
|
||||||
|
/// <param name="model">The model to provide to the partial view that will be rendered.</param>
|
||||||
|
/// <returns>A <see cref="Task"/> that represents when rendering has completed.</returns>
|
||||||
|
public static Task RenderPartialAsync<TModel>([NotNull] this IHtmlHelper<TModel> htmlHelper,
|
||||||
|
[NotNull] string partialViewName, object model)
|
||||||
|
{
|
||||||
|
return htmlHelper.RenderPartialAsync(partialViewName, model, htmlHelper.ViewData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
|
{
|
||||||
|
public static class HtmlHelperValidationExtensions
|
||||||
|
{
|
||||||
|
public static HtmlString ValidationSummary<TModel>([NotNull] this IHtmlHelper<TModel> htmlHelper)
|
||||||
|
{
|
||||||
|
return ValidationSummary(htmlHelper, excludePropertyErrors: false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HtmlString ValidationSummary<TModel>([NotNull] this IHtmlHelper<TModel> htmlHelper,
|
||||||
|
bool excludePropertyErrors)
|
||||||
|
{
|
||||||
|
return ValidationSummary(htmlHelper, excludePropertyErrors, message: null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HtmlString ValidationSummary<TModel>([NotNull] this IHtmlHelper<TModel> htmlHelper,
|
||||||
|
string message)
|
||||||
|
{
|
||||||
|
return ValidationSummary(htmlHelper, excludePropertyErrors: false, message: message,
|
||||||
|
htmlAttributes: (object)null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HtmlString ValidationSummary<TModel>([NotNull] this IHtmlHelper<TModel> htmlHelper,
|
||||||
|
bool excludePropertyErrors, string message)
|
||||||
|
{
|
||||||
|
return ValidationSummary(htmlHelper, excludePropertyErrors, message, htmlAttributes: (object)null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HtmlString ValidationSummary<TModel>([NotNull] this IHtmlHelper<TModel> htmlHelper,
|
||||||
|
string message, object htmlAttributes)
|
||||||
|
{
|
||||||
|
return ValidationSummary(htmlHelper, excludePropertyErrors: false, message: message,
|
||||||
|
htmlAttributes: HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HtmlString ValidationSummary<TModel>([NotNull] this IHtmlHelper<TModel> htmlHelper,
|
||||||
|
bool excludePropertyErrors, string message, object htmlAttributes)
|
||||||
|
{
|
||||||
|
return htmlHelper.ValidationSummary(excludePropertyErrors, message,
|
||||||
|
HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HtmlString ValidationSummary<TModel>([NotNull] this IHtmlHelper<TModel> htmlHelper,
|
||||||
|
string message, IDictionary<string, object> htmlAttributes)
|
||||||
|
{
|
||||||
|
return htmlHelper.ValidationSummary(excludePropertyErrors: false, message: message,
|
||||||
|
htmlAttributes: htmlAttributes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,55 +0,0 @@
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.Rendering
|
|
||||||
{
|
|
||||||
public static class PartialAsyncExtensions
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Renders the partial view with the parent's view data and model to a string.
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T">The <see cref="Type"/> of the model.</typeparam>
|
|
||||||
/// <param name="htmlHelper">The <see cref="HtmlHelper"/> instance that this method extends.</param>
|
|
||||||
/// <param name="partialViewName">The name of the partial view to render.</param>
|
|
||||||
/// <returns>
|
|
||||||
/// A <see cref="Task{T}"/> that represents when rendering to the <see cref="HtmlString"/> has completed.
|
|
||||||
/// </returns>
|
|
||||||
public static Task<HtmlString> PartialAsync<T>(this IHtmlHelper<T> htmlHelper, [NotNull] string partialViewName)
|
|
||||||
{
|
|
||||||
return htmlHelper.PartialAsync(partialViewName, htmlHelper.ViewData.Model, viewData: null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Renders the partial view with the given view data and, implicitly, the given view data's model to a string.
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T">The <see cref="Type"/> of the model.</typeparam>
|
|
||||||
/// <param name="htmlHelper">The <see cref="HtmlHelper"/> instance that this method extends.</param>
|
|
||||||
/// <param name="partialViewName">The name of the partial view to render.</param>
|
|
||||||
/// <param name="viewData">
|
|
||||||
/// The <see cref="ViewDataDictionary"/> that is provided to the partial view that will be rendered.
|
|
||||||
/// </param>
|
|
||||||
/// <returns>
|
|
||||||
/// A <see cref="Task{T}"/> that represents when rendering to the <see cref="HtmlString"/> has completed.
|
|
||||||
/// </returns>
|
|
||||||
public static Task<HtmlString> PartialAsync<T>(this IHtmlHelper<T> htmlHelper, [NotNull] string partialViewName,
|
|
||||||
ViewDataDictionary viewData)
|
|
||||||
{
|
|
||||||
return htmlHelper.PartialAsync(partialViewName, htmlHelper.ViewData.Model, viewData: viewData);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Renders the partial view with an empty view data and the given model to a string.
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T">The <see cref="Type"/> of the model.</typeparam>
|
|
||||||
/// <param name="htmlHelper">The <see cref="HtmlHelper"/> instance that this method extends.</param>
|
|
||||||
/// <param name="partialViewName">The name of the partial view to render.</param>
|
|
||||||
/// <param name="model">The model to provide to the partial view that will be rendered.</param>
|
|
||||||
/// <returns>
|
|
||||||
/// A <see cref="Task{T}"/> that represents when rendering to the <see cref="HtmlString"/> has completed.
|
|
||||||
/// </returns>
|
|
||||||
public static Task<HtmlString> PartialAsync<T>(this IHtmlHelper<T> htmlHelper, [NotNull] string partialViewName,
|
|
||||||
object model)
|
|
||||||
{
|
|
||||||
return htmlHelper.PartialAsync(partialViewName, model, viewData: null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,51 +0,0 @@
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.Rendering
|
|
||||||
{
|
|
||||||
public static class RenderPartialAsyncExtensions
|
|
||||||
{
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Renders the partial view with the parent's view data and model.
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T">The <see cref="Type"/> of the model.</typeparam>
|
|
||||||
/// <param name="htmlHelper">The <see cref="HtmlHelper"/> instance that this method extends.</param>
|
|
||||||
/// <param name="partialViewName">The name of the partial view to render.</param>
|
|
||||||
/// <returns>A <see cref="Task"/> that represents when rendering has completed.</returns>
|
|
||||||
public static Task RenderPartialAsync<T>(this IHtmlHelper<T> htmlHelper, [NotNull] string partialViewName)
|
|
||||||
{
|
|
||||||
return htmlHelper.RenderPartialAsync(partialViewName, htmlHelper.ViewData.Model,
|
|
||||||
viewData: htmlHelper.ViewData);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Renders the partial view with the given view data and, implicitly, the given view data's model.
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T">The <see cref="Type"/> of the model.</typeparam>
|
|
||||||
/// <param name="htmlHelper">The <see cref="HtmlHelper"/> instance that this method extends.</param>
|
|
||||||
/// <param name="partialViewName">The name of the partial view to render.</param>
|
|
||||||
/// <param name="viewData">
|
|
||||||
/// The <see cref="ViewDataDictionary"/> that is provided to the partial view that will be rendered.
|
|
||||||
/// </param>
|
|
||||||
/// <returns>A <see cref="Task"/> that represents when rendering has completed.</returns>
|
|
||||||
public static Task RenderPartialAsync<T>(this IHtmlHelper<T> htmlHelper, [NotNull] string partialViewName,
|
|
||||||
ViewDataDictionary viewData)
|
|
||||||
{
|
|
||||||
return htmlHelper.RenderPartialAsync(partialViewName, htmlHelper.ViewData.Model, viewData: viewData);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Renders the partial view with an empty view data and the given model.
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T">The <see cref="Type"/> of the model.</typeparam>
|
|
||||||
/// <param name="htmlHelper">The <see cref="HtmlHelper"/> instance that this method extends.</param>
|
|
||||||
/// <param name="partialViewName">The name of the partial view to render.</param>
|
|
||||||
/// <param name="model">The model to provide to the partial view that will be rendered.</param>
|
|
||||||
/// <returns>A <see cref="Task"/> that represents when rendering has completed.</returns>
|
|
||||||
public static Task RenderPartialAsync<T>(this IHtmlHelper<T> htmlHelper, [NotNull] string partialViewName,
|
|
||||||
object model)
|
|
||||||
{
|
|
||||||
return htmlHelper.RenderPartialAsync(partialViewName, model, htmlHelper.ViewData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.Rendering
|
|
||||||
{
|
|
||||||
public static class ValidationExtensions
|
|
||||||
{
|
|
||||||
public static HtmlString ValidationSummary<T>(this IHtmlHelper<T> htmlHelper)
|
|
||||||
{
|
|
||||||
return ValidationSummary(htmlHelper, excludePropertyErrors: false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HtmlString ValidationSummary<T>(this IHtmlHelper<T> htmlHelper, bool excludePropertyErrors)
|
|
||||||
{
|
|
||||||
return ValidationSummary(htmlHelper, excludePropertyErrors, message: null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HtmlString ValidationSummary<T>(this IHtmlHelper<T> htmlHelper, string message)
|
|
||||||
{
|
|
||||||
return ValidationSummary(htmlHelper, excludePropertyErrors: false, message: message, htmlAttributes: (object)null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HtmlString ValidationSummary<T>(this IHtmlHelper<T> htmlHelper, bool excludePropertyErrors, string message)
|
|
||||||
{
|
|
||||||
return ValidationSummary(htmlHelper, excludePropertyErrors, message, htmlAttributes: (object)null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HtmlString ValidationSummary<T>(this IHtmlHelper<T> htmlHelper, string message, object htmlAttributes)
|
|
||||||
{
|
|
||||||
return ValidationSummary(htmlHelper, excludePropertyErrors: false, message: message, htmlAttributes: HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HtmlString ValidationSummary<T>(this IHtmlHelper<T> htmlHelper, bool excludePropertyErrors, string message, object htmlAttributes)
|
|
||||||
{
|
|
||||||
return htmlHelper.ValidationSummary(excludePropertyErrors, message, HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HtmlString ValidationSummary<T>(this IHtmlHelper<T> htmlHelper, string message, IDictionary<string, object> htmlAttributes)
|
|
||||||
{
|
|
||||||
return htmlHelper.ValidationSummary(excludePropertyErrors: false, message: message, htmlAttributes: htmlAttributes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -22,8 +22,5 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="MvcServices.cs" />
|
<Compile Include="MvcServices.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="Properties\" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VSToolsPath)\ProjectK\Microsoft.Web.ProjectK.targets" Condition="'$(VSToolsPath)' != ''" />
|
<Import Project="$(VSToolsPath)\ProjectK\Microsoft.Web.ProjectK.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -36,8 +36,5 @@
|
||||||
<Compile Include="TypeHelperTest.cs" />
|
<Compile Include="TypeHelperTest.cs" />
|
||||||
<Compile Include="UrlHelperTest.cs" />
|
<Compile Include="UrlHelperTest.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="Properties\" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VSToolsPath)\ProjectK\Microsoft.Web.ProjectK.targets" Condition="'$(VSToolsPath)' != ''" />
|
<Import Project="$(VSToolsPath)\ProjectK\Microsoft.Web.ProjectK.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -50,8 +50,5 @@
|
||||||
<Compile Include="ValueProviders\ReadableStringCollectionValueProviderTests.cs" />
|
<Compile Include="ValueProviders\ReadableStringCollectionValueProviderTests.cs" />
|
||||||
<Compile Include="ValueProviders\ValueProviderResultTest.cs" />
|
<Compile Include="ValueProviders\ValueProviderResultTest.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="Properties\" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VSToolsPath)\ProjectK\Microsoft.Web.ProjectK.targets" Condition="'$(VSToolsPath)' != ''" />
|
<Import Project="$(VSToolsPath)\ProjectK\Microsoft.Web.ProjectK.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -26,8 +26,5 @@
|
||||||
<Compile Include="RazorViewTest.cs" />
|
<Compile Include="RazorViewTest.cs" />
|
||||||
<Compile Include="SpanFactory.cs" />
|
<Compile Include="SpanFactory.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="Properties\" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VSToolsPath)\ProjectK\Microsoft.Web.ProjectK.targets" Condition="'$(VSToolsPath)' != ''" />
|
<Import Project="$(VSToolsPath)\ProjectK\Microsoft.Web.ProjectK.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||||
</Project>
|
</Project>
|
||||||
Loading…
Reference in New Issue