Incorporate breaking changes from MVC TagBuilder
This commit is contained in:
parent
540bcc7950
commit
17588a4089
|
|
@ -5,39 +5,40 @@ using System.Linq;
|
|||
using System.Linq.Expressions;
|
||||
using Microsoft.AspNet.Mvc.Rendering.Expressions;
|
||||
using Microsoft.AspNet.Routing;
|
||||
using Microsoft.AspNet.Html.Abstractions;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.Rendering
|
||||
{
|
||||
public static class AngularExtensions
|
||||
{
|
||||
public static HtmlString ngPasswordFor<TModel, TProperty>(this IHtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> expression)
|
||||
public static IHtmlContent ngPasswordFor<TModel, TProperty>(this IHtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> expression)
|
||||
{
|
||||
return html.ngPasswordFor(expression, null);
|
||||
}
|
||||
|
||||
public static HtmlString ngPasswordFor<TModel, TProperty>(this IHtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> expression, object htmlAttributes)
|
||||
public static IHtmlContent ngPasswordFor<TModel, TProperty>(this IHtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> expression, object htmlAttributes)
|
||||
{
|
||||
return html.ngPasswordFor(expression, HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes));
|
||||
}
|
||||
|
||||
public static HtmlString ngPasswordFor<TModel, TProperty>(this IHtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> expression, IDictionary<string, object> htmlAttributes)
|
||||
public static IHtmlContent ngPasswordFor<TModel, TProperty>(this IHtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> expression, IDictionary<string, object> htmlAttributes)
|
||||
{
|
||||
return html.ngTextBoxFor(expression, MergeAttributes(
|
||||
new RouteValueDictionary { { "type", "password" } },
|
||||
htmlAttributes));
|
||||
}
|
||||
|
||||
public static HtmlString ngTextBoxFor<TModel, TProperty>(this IHtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> expression)
|
||||
public static IHtmlContent ngTextBoxFor<TModel, TProperty>(this IHtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> expression)
|
||||
{
|
||||
return html.ngTextBoxFor(expression, new RouteValueDictionary());
|
||||
}
|
||||
|
||||
public static HtmlString ngTextBoxFor<TModel, TProperty>(this IHtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> expression, object htmlAttributes)
|
||||
public static IHtmlContent ngTextBoxFor<TModel, TProperty>(this IHtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> expression, object htmlAttributes)
|
||||
{
|
||||
return html.ngTextBoxFor(expression, HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes));
|
||||
}
|
||||
|
||||
public static HtmlString ngTextBoxFor<TModel, TProperty>(this IHtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> expression, IDictionary<string, object> htmlAttributes)
|
||||
public static IHtmlContent ngTextBoxFor<TModel, TProperty>(this IHtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> expression, IDictionary<string, object> htmlAttributes)
|
||||
{
|
||||
var expressionText = ExpressionHelper.GetExpressionText(expression);
|
||||
var modelExplorer = ExpressionMetadataProvider.FromLambdaExpression(expression, html.ViewData, html.MetadataProvider);
|
||||
|
|
@ -140,27 +141,9 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
|||
|
||||
var tag = new TagBuilder("input");
|
||||
tag.MergeAttributes(MergeAttributes(ngAttributes, htmlAttributes));
|
||||
return tag.ToHtmlString(TagRenderMode.SelfClosing);
|
||||
return tag.ToHtmlContent(TagRenderMode.SelfClosing);
|
||||
}
|
||||
|
||||
//private static bool IsNumberType(Type type)
|
||||
//{
|
||||
// switch (Type.GetTypeCode(type))
|
||||
// {
|
||||
// case TypeCode.Int16:
|
||||
// case TypeCode.Int32:
|
||||
// case TypeCode.Int64:
|
||||
// case TypeCode.UInt16:
|
||||
// case TypeCode.UInt32:
|
||||
// case TypeCode.UInt64:
|
||||
// case TypeCode.Decimal:
|
||||
// case TypeCode.Double:
|
||||
// case TypeCode.Single:
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
//}
|
||||
|
||||
private static bool IsNumberType(Type type)
|
||||
{
|
||||
if (type == typeof(Int16) ||
|
||||
|
|
@ -207,12 +190,12 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
|||
return false;
|
||||
}
|
||||
|
||||
public static HtmlString ngDropDownListFor<TModel, TProperty, TDisplayProperty>(this IHtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> propertyExpression, Expression<Func<TModel, TDisplayProperty>> displayExpression, string source, string nullOption, object htmlAttributes)
|
||||
public static IHtmlContent ngDropDownListFor<TModel, TProperty, TDisplayProperty>(this IHtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> propertyExpression, Expression<Func<TModel, TDisplayProperty>> displayExpression, string source, string nullOption, object htmlAttributes)
|
||||
{
|
||||
return ngDropDownListFor(html, propertyExpression, displayExpression, source, nullOption, HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes));
|
||||
}
|
||||
|
||||
public static HtmlString ngDropDownListFor<TModel, TProperty, TDisplayProperty>(this IHtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> propertyExpression, Expression<Func<TModel, TDisplayProperty>> displayExpression, string source, string nullOption, IDictionary<string, object> htmlAttributes)
|
||||
public static IHtmlContent ngDropDownListFor<TModel, TProperty, TDisplayProperty>(this IHtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> propertyExpression, Expression<Func<TModel, TDisplayProperty>> displayExpression, string source, string nullOption, IDictionary<string, object> htmlAttributes)
|
||||
{
|
||||
var propertyExpressionText = ExpressionHelper.GetExpressionText(propertyExpression);
|
||||
var displayExpressionText = ExpressionHelper.GetExpressionText(displayExpression);
|
||||
|
|
@ -238,7 +221,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
|||
var nullOptionTag = new TagBuilder("option");
|
||||
nullOptionTag.Attributes["value"] = string.Empty;
|
||||
nullOptionTag.SetInnerText(nullOption);
|
||||
tag.InnerHtml = nullOptionTag.ToString();
|
||||
tag.InnerHtml = nullOptionTag.ToHtmlContent(TagRenderMode.Normal);
|
||||
}
|
||||
|
||||
var clientValidators = html.GetClientValidationRules(metadata, null);
|
||||
|
|
@ -250,20 +233,20 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
|||
|
||||
tag.MergeAttributes(htmlAttributes, replaceExisting: true);
|
||||
|
||||
return tag.ToHtmlString(TagRenderMode.Normal);
|
||||
return tag.ToHtmlContent(TagRenderMode.Normal);
|
||||
}
|
||||
|
||||
public static HtmlString ngValidationMessageFor<TModel, TProperty>(this IHtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, string formName)
|
||||
public static IHtmlContent ngValidationMessageFor<TModel, TProperty>(this IHtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, string formName)
|
||||
{
|
||||
return ngValidationMessageFor(htmlHelper, expression, formName, ((IDictionary<string, object>)new RouteValueDictionary()));
|
||||
}
|
||||
|
||||
public static HtmlString ngValidationMessageFor<TModel, TProperty>(this IHtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, string formName, object htmlAttributes)
|
||||
public static IHtmlContent ngValidationMessageFor<TModel, TProperty>(this IHtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, string formName, object htmlAttributes)
|
||||
{
|
||||
return ngValidationMessageFor(htmlHelper, expression, formName, HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes));
|
||||
}
|
||||
|
||||
public static HtmlString ngValidationMessageFor<TModel, TProperty>(this IHtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> expression, string formName, IDictionary<string, object> htmlAttributes)
|
||||
public static IHtmlContent ngValidationMessageFor<TModel, TProperty>(this IHtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> expression, string formName, IDictionary<string, object> htmlAttributes)
|
||||
{
|
||||
var expressionText = ExpressionHelper.GetExpressionText(expression);
|
||||
var metadata = ExpressionMetadataProvider.FromLambdaExpression(expression, html.ViewData, html.MetadataProvider);
|
||||
|
|
@ -309,7 +292,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
|||
tags.Add(tag);
|
||||
}
|
||||
|
||||
return html.Raw(String.Concat(tags.Select(t => t.ToString())));
|
||||
return new HtmlString(String.Concat(tags.Select(t => t.ToString())));
|
||||
}
|
||||
|
||||
public static string ngValidationClassFor<TModel, TProperty>(this IHtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> expression, string formName, string className)
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.Rendering
|
||||
{
|
||||
public static class GeneralExtensions
|
||||
{
|
||||
public static HtmlString Tag(this IHtmlHelper htmlHelper, TagBuilder tagBuilder)
|
||||
{
|
||||
return htmlHelper.Raw(tagBuilder.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,37 +1,36 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNet.Routing;
|
||||
using Newtonsoft.Json;
|
||||
using Microsoft.AspNet.Html.Abstractions;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.Rendering
|
||||
{
|
||||
public static class JsonExtensions
|
||||
{
|
||||
public static HtmlString Json<T, TData>(this IHtmlHelper<T> helper, TData data)
|
||||
public static IHtmlContent Json<T, TData>(this IHtmlHelper<T> helper, TData data)
|
||||
{
|
||||
return Json(helper, data, new RouteValueDictionary());
|
||||
}
|
||||
|
||||
public static HtmlString Json<T, TData>(this IHtmlHelper<T> helper, TData data, object htmlAttributes)
|
||||
public static IHtmlContent Json<T, TData>(this IHtmlHelper<T> helper, TData data, object htmlAttributes)
|
||||
{
|
||||
return Json(helper, data, HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes));
|
||||
}
|
||||
|
||||
public static HtmlString Json<T, TData>(this IHtmlHelper<T> helper, TData data, IDictionary<string, object> htmlAttributes)
|
||||
public static IHtmlContent Json<T, TData>(this IHtmlHelper<T> helper, TData data, IDictionary<string, object> htmlAttributes)
|
||||
{
|
||||
var builder = new TagBuilder("script");
|
||||
builder.Attributes["type"] = "application/json";
|
||||
builder.MergeAttributes(htmlAttributes);
|
||||
builder.InnerHtml =
|
||||
(data is JsonString
|
||||
? data.ToString()
|
||||
: JsonConvert.SerializeObject(data))
|
||||
.Replace("<", "\u003C").Replace(">", "\u003E");
|
||||
|
||||
return helper.Tag(builder);
|
||||
var innerContent = data is JsonString ? data.ToString() : JsonConvert.SerializeObject(data);
|
||||
innerContent.Replace("<", "\u003C").Replace(">", "\u003E");
|
||||
builder.InnerHtml = new HtmlString(innerContent);
|
||||
|
||||
return builder.ToHtmlContent(TagRenderMode.Normal);
|
||||
}
|
||||
|
||||
public static HtmlString InlineData<T>(this IHtmlHelper<T> helper, string actionName, string controllerName)
|
||||
public static IHtmlContent InlineData<T>(this IHtmlHelper<T> helper, string actionName, string controllerName)
|
||||
{
|
||||
//var result = helper.Action(actionName, controllerName);
|
||||
//var urlHelper = new UrlHelper(helper.ViewContext.RequestContext);
|
||||
|
|
|
|||
Loading…
Reference in New Issue