Call `IHtmlHelper` methods from extension methods

- don't call other extension methods
- #847 line 7
- remove extension methods that do nothing but pass through to the interface method
 - weren't exactly ambiguous (interface method wins) but were useless
This commit is contained in:
dougbu 2014-08-05 11:56:41 -07:00
parent 56d66c090e
commit 4c5aa15f0b
4 changed files with 8 additions and 83 deletions

View File

@ -107,7 +107,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
public static HtmlString TextBox([NotNull] this IHtmlHelper htmlHelper, string name)
{
return TextBox(htmlHelper, name, value: null);
return htmlHelper.TextBox(name, value: null, format: null, htmlAttributes: null);
}
public static HtmlString TextBox(
@ -115,7 +115,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
string name,
object value)
{
return TextBox(htmlHelper, name, value, format: null);
return htmlHelper.TextBox(name, value, format: null, htmlAttributes: null);
}
public static HtmlString TextBox(
@ -124,7 +124,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
object value,
string format)
{
return TextBox(htmlHelper, name, value, format, htmlAttributes: null);
return htmlHelper.TextBox(name, value, format, htmlAttributes: null);
}
public static HtmlString TextBox(
@ -133,41 +133,25 @@ namespace Microsoft.AspNet.Mvc.Rendering
object value,
object htmlAttributes)
{
return TextBox(htmlHelper, name, value, format: null, htmlAttributes: htmlAttributes);
}
public static HtmlString TextBox(
[NotNull] this IHtmlHelper htmlHelper,
string name,
object value,
string format,
object htmlAttributes)
{
return htmlHelper.TextBox(name, value, format, htmlAttributes);
return htmlHelper.TextBox(name, value, format: null, htmlAttributes: htmlAttributes);
}
public static HtmlString TextBoxFor<TModel, TProperty>([NotNull] this IHtmlHelper<TModel> htmlHelper,
[NotNull] Expression<Func<TModel, TProperty>> expression)
{
return TextBoxFor(htmlHelper, expression, format: null);
return htmlHelper.TextBoxFor(expression, format: null, htmlAttributes: null);
}
public static HtmlString TextBoxFor<TModel, TProperty>([NotNull] this IHtmlHelper<TModel> htmlHelper,
[NotNull] Expression<Func<TModel, TProperty>> expression, string format)
{
return TextBoxFor(htmlHelper, expression, format, htmlAttributes: null);
return htmlHelper.TextBoxFor(expression, format, htmlAttributes: null);
}
public static HtmlString TextBoxFor<TModel, TProperty>([NotNull] this IHtmlHelper<TModel> htmlHelper,
[NotNull] Expression<Func<TModel, TProperty>> expression, object htmlAttributes)
{
return TextBoxFor(htmlHelper, expression, format: null, htmlAttributes: htmlAttributes);
}
public static HtmlString TextBoxFor<TModel, TProperty>([NotNull] this IHtmlHelper<TModel> htmlHelper,
[NotNull] Expression<Func<TModel, TProperty>> expression, string format, object htmlAttributes)
{
return htmlHelper.TextBoxFor(expression, format: format, htmlAttributes: htmlAttributes);
return htmlHelper.TextBoxFor(expression, format: null, htmlAttributes: htmlAttributes);
}
public static HtmlString TextArea([NotNull] this IHtmlHelper htmlHelper,
@ -194,12 +178,6 @@ namespace Microsoft.AspNet.Mvc.Rendering
return htmlHelper.TextArea(name, value, rows: 0, columns: 0, htmlAttributes: htmlAttributes);
}
public static HtmlString TextArea([NotNull] this IHtmlHelper htmlHelper,
string name, string value, int rows, int columns, object htmlAttributes)
{
return htmlHelper.TextArea(name, value, rows, columns, htmlAttributes);
}
public static HtmlString TextAreaFor<TModel, TProperty>([NotNull] this IHtmlHelper<TModel> htmlHelper,
[NotNull] Expression<Func<TModel, TProperty>> expression)
{
@ -211,11 +189,5 @@ namespace Microsoft.AspNet.Mvc.Rendering
{
return htmlHelper.TextAreaFor(expression, rows: 0, columns: 0, htmlAttributes: htmlAttributes);
}
public static HtmlString TextAreaFor<TModel, TProperty>([NotNull] this IHtmlHelper<TModel> htmlHelper,
[NotNull] Expression<Func<TModel, TProperty>> expression, int rows, int columns, object htmlAttributes)
{
return htmlHelper.TextAreaFor(expression, rows, columns, htmlAttributes);
}
}
}

View File

@ -42,7 +42,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
public static HtmlString LabelForModel([NotNull] this IHtmlHelper html)
{
return LabelForModel(html, labelText: null);
return html.Label(expression: null, labelText: null, htmlAttributes: null);
}
public static HtmlString LabelForModel([NotNull] this IHtmlHelper html, string labelText)

View File

@ -188,25 +188,5 @@ namespace Microsoft.AspNet.Mvc.Rendering
routeValues: routeValues,
htmlAttributes: htmlAttributes);
}
public static HtmlString RouteLink(
[NotNull] this IHtmlHelper htmlHelper,
[NotNull] string linkText,
string routeName,
string protocol,
string hostName,
string fragment,
object routeValues,
object htmlAttributes)
{
return htmlHelper.RouteLink(
linkText,
routeName,
protocol,
hostName,
fragment,
routeValues,
htmlAttributes);
}
}
}

View File

@ -44,15 +44,6 @@ namespace Microsoft.AspNet.Mvc.Rendering
return htmlHelper.ValidationMessage(expression, message, htmlAttributes, tag: null);
}
public static HtmlString ValidationMessage([NotNull] this IHtmlHelper htmlHelper,
string expression,
string message,
object htmlAttributes,
string tag)
{
return htmlHelper.ValidationMessage(expression, message, htmlAttributes, tag);
}
public static HtmlString ValidationMessageFor<TModel, TProperty>([NotNull] this IHtmlHelper<TModel> htmlHelper,
[NotNull] Expression<Func<TModel, TProperty>> expression)
{
@ -82,15 +73,6 @@ namespace Microsoft.AspNet.Mvc.Rendering
return htmlHelper.ValidationMessageFor(expression, message, htmlAttributes: null, tag: tag);
}
public static HtmlString ValidationMessageFor<TModel, TProperty>([NotNull] this IHtmlHelper<TModel> htmlHelper,
[NotNull] Expression<Func<TModel, TProperty>> expression,
string message,
object htmlAttributes,
string tag)
{
return htmlHelper.ValidationMessageFor(expression, message, htmlAttributes, tag);
}
public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper)
{
return htmlHelper.ValidationSummary(excludePropertyErrors: false,
@ -168,14 +150,5 @@ namespace Microsoft.AspNet.Mvc.Rendering
{
return htmlHelper.ValidationSummary(excludePropertyErrors, message, htmlAttributes, tag: null);
}
public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper,
bool excludePropertyErrors,
string message,
object htmlAttributes,
string tag)
{
return htmlHelper.ValidationSummary(excludePropertyErrors, message, htmlAttributes, tag);
}
}
}