Replace NotNullAttribute with thrown exceptions
This commit is contained in:
parent
eff10cdd66
commit
18c80d156c
|
|
@ -18,15 +18,7 @@
|
||||||
"Microsoft.AspNet.Server.WebListener": "1.0.0-*",
|
"Microsoft.AspNet.Server.WebListener": "1.0.0-*",
|
||||||
"Microsoft.AspNet.Session": "1.0.0-*",
|
"Microsoft.AspNet.Session": "1.0.0-*",
|
||||||
"Microsoft.AspNet.StaticFiles": "1.0.0-*",
|
"Microsoft.AspNet.StaticFiles": "1.0.0-*",
|
||||||
"Microsoft.Framework.Configuration.Json": "1.0.0-*",
|
"Microsoft.Framework.Configuration.Json": "1.0.0-*"
|
||||||
"Microsoft.Framework.PropertyHelper.Sources": {
|
|
||||||
"version": "1.0.0-*",
|
|
||||||
"type": "build"
|
|
||||||
},
|
|
||||||
"Microsoft.Framework.NotNullAttribute.Sources": {
|
|
||||||
"type": "build",
|
|
||||||
"version": "1.0.0-*"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"frameworks": {
|
"frameworks": {
|
||||||
"dnx451": { },
|
"dnx451": { },
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,7 @@
|
||||||
"Microsoft.AspNet.Server.IIS": "1.0.0-*",
|
"Microsoft.AspNet.Server.IIS": "1.0.0-*",
|
||||||
"Microsoft.AspNet.Server.WebListener": "1.0.0-*",
|
"Microsoft.AspNet.Server.WebListener": "1.0.0-*",
|
||||||
"Microsoft.AspNet.StaticFiles": "1.0.0-*",
|
"Microsoft.AspNet.StaticFiles": "1.0.0-*",
|
||||||
"Microsoft.AspNet.Tooling.Razor": "1.0.0-*",
|
"Microsoft.AspNet.Tooling.Razor": "1.0.0-*"
|
||||||
"Microsoft.Framework.NotNullAttribute.Sources": { "type": "build", "version": "1.0.0-*" },
|
|
||||||
"Microsoft.Framework.PropertyHelper.Sources": { "version": "1.0.0-*", "type": "build" }
|
|
||||||
},
|
},
|
||||||
"frameworks": {
|
"frameworks": {
|
||||||
"dnx451": { },
|
"dnx451": { },
|
||||||
|
|
|
||||||
|
|
@ -147,14 +147,15 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
|
||||||
TagBuilder tagBuilder;
|
TagBuilder tagBuilder;
|
||||||
if (Route == null)
|
if (Route == null)
|
||||||
{
|
{
|
||||||
tagBuilder = Generator.GenerateActionLink(linkText: string.Empty,
|
tagBuilder = Generator.GenerateActionLink(
|
||||||
actionName: Action,
|
linkText: string.Empty,
|
||||||
controllerName: Controller,
|
actionName: Action,
|
||||||
protocol: Protocol,
|
controllerName: Controller,
|
||||||
hostname: Host,
|
protocol: Protocol,
|
||||||
fragment: Fragment,
|
hostname: Host,
|
||||||
routeValues: routeValues,
|
fragment: Fragment,
|
||||||
htmlAttributes: null);
|
routeValues: routeValues,
|
||||||
|
htmlAttributes: null);
|
||||||
}
|
}
|
||||||
else if (Action != null || Controller != null)
|
else if (Action != null || Controller != null)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -104,8 +104,8 @@ namespace Microsoft.AspNet.Mvc
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// <see cref="Controllers.IControllerActivator"/> activates this property while activating controllers.
|
/// <see cref="Controllers.IControllerActivator"/> activates this property while activating controllers.
|
||||||
/// If user code directly instantiates a controller, the getter returns an empty
|
/// If user code directly instantiates a controller, the getter returns an empty
|
||||||
/// <see cref="Mvc.ActionContext"/>.
|
/// <see cref="Mvc.ActionContext"/>.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[ActionContext]
|
[ActionContext]
|
||||||
public ActionContext ActionContext
|
public ActionContext ActionContext
|
||||||
|
|
@ -147,10 +147,13 @@ namespace Microsoft.AspNet.Mvc
|
||||||
|
|
||||||
return _metadataProvider;
|
return _metadataProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
[param: NotNull]
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
if (value == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(value));
|
||||||
|
}
|
||||||
|
|
||||||
_metadataProvider = value;
|
_metadataProvider = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -169,10 +172,13 @@ namespace Microsoft.AspNet.Mvc
|
||||||
|
|
||||||
return _url;
|
return _url;
|
||||||
}
|
}
|
||||||
|
|
||||||
[param: NotNull]
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
if (value == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(value));
|
||||||
|
}
|
||||||
|
|
||||||
_url = value;
|
_url = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -191,10 +197,13 @@ namespace Microsoft.AspNet.Mvc
|
||||||
|
|
||||||
return _objectValidator;
|
return _objectValidator;
|
||||||
}
|
}
|
||||||
|
|
||||||
[param: NotNull]
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
if (value == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(value));
|
||||||
|
}
|
||||||
|
|
||||||
_objectValidator = value;
|
_objectValidator = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -259,10 +268,13 @@ namespace Microsoft.AspNet.Mvc
|
||||||
|
|
||||||
return _tempData;
|
return _tempData;
|
||||||
}
|
}
|
||||||
|
|
||||||
[param: NotNull]
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
if (value == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(value));
|
||||||
|
}
|
||||||
|
|
||||||
_tempData = value;
|
_tempData = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -525,8 +537,13 @@ namespace Microsoft.AspNet.Mvc
|
||||||
/// <remarks>Callers should cache an instance of <see cref="JsonSerializerSettings"/> to avoid
|
/// <remarks>Callers should cache an instance of <see cref="JsonSerializerSettings"/> to avoid
|
||||||
/// recreating cached data with each call.</remarks>
|
/// recreating cached data with each call.</remarks>
|
||||||
[NonAction]
|
[NonAction]
|
||||||
public virtual JsonResult Json(object data, [NotNull] JsonSerializerSettings serializerSettings)
|
public virtual JsonResult Json(object data, JsonSerializerSettings serializerSettings)
|
||||||
{
|
{
|
||||||
|
if (serializerSettings == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(serializerSettings));
|
||||||
|
}
|
||||||
|
|
||||||
var disposableValue = data as IDisposable;
|
var disposableValue = data as IDisposable;
|
||||||
if (disposableValue != null)
|
if (disposableValue != null)
|
||||||
{
|
{
|
||||||
|
|
@ -981,8 +998,13 @@ namespace Microsoft.AspNet.Mvc
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The created <see cref="BadRequestObjectResult"/> for the response.</returns>
|
/// <returns>The created <see cref="BadRequestObjectResult"/> for the response.</returns>
|
||||||
[NonAction]
|
[NonAction]
|
||||||
public virtual BadRequestObjectResult HttpBadRequest([NotNull] ModelStateDictionary modelState)
|
public virtual BadRequestObjectResult HttpBadRequest(ModelStateDictionary modelState)
|
||||||
{
|
{
|
||||||
|
if (modelState == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(modelState));
|
||||||
|
}
|
||||||
|
|
||||||
return new BadRequestObjectResult(modelState);
|
return new BadRequestObjectResult(modelState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -993,8 +1015,13 @@ namespace Microsoft.AspNet.Mvc
|
||||||
/// <param name="value">The content value to format in the entity body.</param>
|
/// <param name="value">The content value to format in the entity body.</param>
|
||||||
/// <returns>The created <see cref="CreatedResult"/> for the response.</returns>
|
/// <returns>The created <see cref="CreatedResult"/> for the response.</returns>
|
||||||
[NonAction]
|
[NonAction]
|
||||||
public virtual CreatedResult Created([NotNull] string uri, object value)
|
public virtual CreatedResult Created(string uri, object value)
|
||||||
{
|
{
|
||||||
|
if (uri == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(uri));
|
||||||
|
}
|
||||||
|
|
||||||
var disposableValue = value as IDisposable;
|
var disposableValue = value as IDisposable;
|
||||||
if (disposableValue != null)
|
if (disposableValue != null)
|
||||||
{
|
{
|
||||||
|
|
@ -1011,14 +1038,19 @@ namespace Microsoft.AspNet.Mvc
|
||||||
/// <param name="value">The content value to format in the entity body.</param>
|
/// <param name="value">The content value to format in the entity body.</param>
|
||||||
/// <returns>The created <see cref="CreatedResult"/> for the response.</returns>
|
/// <returns>The created <see cref="CreatedResult"/> for the response.</returns>
|
||||||
[NonAction]
|
[NonAction]
|
||||||
public virtual CreatedResult Created([NotNull] Uri uri, object value)
|
public virtual CreatedResult Created(Uri uri, object value)
|
||||||
{
|
{
|
||||||
|
if (uri == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(uri));
|
||||||
|
}
|
||||||
|
|
||||||
var disposableValue = value as IDisposable;
|
var disposableValue = value as IDisposable;
|
||||||
if (disposableValue != null)
|
if (disposableValue != null)
|
||||||
{
|
{
|
||||||
Response.RegisterForDispose(disposableValue);
|
Response.RegisterForDispose(disposableValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new CreatedResult(uri, value);
|
return new CreatedResult(uri, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1119,8 +1151,12 @@ namespace Microsoft.AspNet.Mvc
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="context">The action executing context.</param>
|
/// <param name="context">The action executing context.</param>
|
||||||
[NonAction]
|
[NonAction]
|
||||||
public virtual void OnActionExecuting([NotNull] ActionExecutingContext context)
|
public virtual void OnActionExecuting(ActionExecutingContext context)
|
||||||
{
|
{
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(context));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1128,8 +1164,12 @@ namespace Microsoft.AspNet.Mvc
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="context">The action executed context.</param>
|
/// <param name="context">The action executed context.</param>
|
||||||
[NonAction]
|
[NonAction]
|
||||||
public virtual void OnActionExecuted([NotNull] ActionExecutedContext context)
|
public virtual void OnActionExecuted(ActionExecutedContext context)
|
||||||
{
|
{
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(context));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1141,9 +1181,19 @@ namespace Microsoft.AspNet.Mvc
|
||||||
/// <returns>A <see cref="Task"/> instance.</returns>
|
/// <returns>A <see cref="Task"/> instance.</returns>
|
||||||
[NonAction]
|
[NonAction]
|
||||||
public virtual async Task OnActionExecutionAsync(
|
public virtual async Task OnActionExecutionAsync(
|
||||||
[NotNull] ActionExecutingContext context,
|
ActionExecutingContext context,
|
||||||
[NotNull] ActionExecutionDelegate next)
|
ActionExecutionDelegate next)
|
||||||
{
|
{
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(context));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (next == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(next));
|
||||||
|
}
|
||||||
|
|
||||||
OnActionExecuting(context);
|
OnActionExecuting(context);
|
||||||
if (context.Result == null)
|
if (context.Result == null)
|
||||||
{
|
{
|
||||||
|
|
@ -1160,9 +1210,14 @@ namespace Microsoft.AspNet.Mvc
|
||||||
/// <returns>A <see cref="Task"/> that on completion returns <c>true</c> if the update is successful.</returns>
|
/// <returns>A <see cref="Task"/> that on completion returns <c>true</c> if the update is successful.</returns>
|
||||||
[NonAction]
|
[NonAction]
|
||||||
public virtual Task<bool> TryUpdateModelAsync<TModel>(
|
public virtual Task<bool> TryUpdateModelAsync<TModel>(
|
||||||
[NotNull] TModel model)
|
TModel model)
|
||||||
where TModel : class
|
where TModel : class
|
||||||
{
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
|
||||||
return TryUpdateModelAsync(model, prefix: string.Empty);
|
return TryUpdateModelAsync(model, prefix: string.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1177,10 +1232,20 @@ namespace Microsoft.AspNet.Mvc
|
||||||
/// <returns>A <see cref="Task"/> that on completion returns <c>true</c> if the update is successful.</returns>
|
/// <returns>A <see cref="Task"/> that on completion returns <c>true</c> if the update is successful.</returns>
|
||||||
[NonAction]
|
[NonAction]
|
||||||
public virtual Task<bool> TryUpdateModelAsync<TModel>(
|
public virtual Task<bool> TryUpdateModelAsync<TModel>(
|
||||||
[NotNull] TModel model,
|
TModel model,
|
||||||
[NotNull] string prefix)
|
string prefix)
|
||||||
where TModel : class
|
where TModel : class
|
||||||
{
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prefix == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(prefix));
|
||||||
|
}
|
||||||
|
|
||||||
if (BindingContext == null)
|
if (BindingContext == null)
|
||||||
{
|
{
|
||||||
var message = Resources.FormatPropertyOfTypeCannotBeNull(
|
var message = Resources.FormatPropertyOfTypeCannotBeNull(
|
||||||
|
|
@ -1204,11 +1269,26 @@ namespace Microsoft.AspNet.Mvc
|
||||||
/// <returns>A <see cref="Task"/> that on completion returns <c>true</c> if the update is successful.</returns>
|
/// <returns>A <see cref="Task"/> that on completion returns <c>true</c> if the update is successful.</returns>
|
||||||
[NonAction]
|
[NonAction]
|
||||||
public virtual Task<bool> TryUpdateModelAsync<TModel>(
|
public virtual Task<bool> TryUpdateModelAsync<TModel>(
|
||||||
[NotNull] TModel model,
|
TModel model,
|
||||||
[NotNull] string prefix,
|
string prefix,
|
||||||
[NotNull] IValueProvider valueProvider)
|
IValueProvider valueProvider)
|
||||||
where TModel : class
|
where TModel : class
|
||||||
{
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prefix == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(prefix));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (valueProvider == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(valueProvider));
|
||||||
|
}
|
||||||
|
|
||||||
if (BindingContext == null)
|
if (BindingContext == null)
|
||||||
{
|
{
|
||||||
var message = Resources.FormatPropertyOfTypeCannotBeNull(
|
var message = Resources.FormatPropertyOfTypeCannotBeNull(
|
||||||
|
|
@ -1243,11 +1323,21 @@ namespace Microsoft.AspNet.Mvc
|
||||||
/// <returns>A <see cref="Task"/> that on completion returns <c>true</c> if the update is successful.</returns>
|
/// <returns>A <see cref="Task"/> that on completion returns <c>true</c> if the update is successful.</returns>
|
||||||
[NonAction]
|
[NonAction]
|
||||||
public Task<bool> TryUpdateModelAsync<TModel>(
|
public Task<bool> TryUpdateModelAsync<TModel>(
|
||||||
[NotNull] TModel model,
|
TModel model,
|
||||||
string prefix,
|
string prefix,
|
||||||
[NotNull] params Expression<Func<TModel, object>>[] includeExpressions)
|
params Expression<Func<TModel, object>>[] includeExpressions)
|
||||||
where TModel : class
|
where TModel : class
|
||||||
{
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (includeExpressions == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(includeExpressions));
|
||||||
|
}
|
||||||
|
|
||||||
if (BindingContext == null)
|
if (BindingContext == null)
|
||||||
{
|
{
|
||||||
var message = Resources.FormatPropertyOfTypeCannotBeNull(
|
var message = Resources.FormatPropertyOfTypeCannotBeNull(
|
||||||
|
|
@ -1282,11 +1372,21 @@ namespace Microsoft.AspNet.Mvc
|
||||||
/// <returns>A <see cref="Task"/> that on completion returns <c>true</c> if the update is successful.</returns>
|
/// <returns>A <see cref="Task"/> that on completion returns <c>true</c> if the update is successful.</returns>
|
||||||
[NonAction]
|
[NonAction]
|
||||||
public Task<bool> TryUpdateModelAsync<TModel>(
|
public Task<bool> TryUpdateModelAsync<TModel>(
|
||||||
[NotNull] TModel model,
|
TModel model,
|
||||||
string prefix,
|
string prefix,
|
||||||
[NotNull] Func<ModelBindingContext, string, bool> predicate)
|
Func<ModelBindingContext, string, bool> predicate)
|
||||||
where TModel : class
|
where TModel : class
|
||||||
{
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (predicate == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(predicate));
|
||||||
|
}
|
||||||
|
|
||||||
if (BindingContext == null)
|
if (BindingContext == null)
|
||||||
{
|
{
|
||||||
var message = Resources.FormatPropertyOfTypeCannotBeNull(
|
var message = Resources.FormatPropertyOfTypeCannotBeNull(
|
||||||
|
|
@ -1323,12 +1423,27 @@ namespace Microsoft.AspNet.Mvc
|
||||||
/// <returns>A <see cref="Task"/> that on completion returns <c>true</c> if the update is successful.</returns>
|
/// <returns>A <see cref="Task"/> that on completion returns <c>true</c> if the update is successful.</returns>
|
||||||
[NonAction]
|
[NonAction]
|
||||||
public Task<bool> TryUpdateModelAsync<TModel>(
|
public Task<bool> TryUpdateModelAsync<TModel>(
|
||||||
[NotNull] TModel model,
|
TModel model,
|
||||||
string prefix,
|
string prefix,
|
||||||
[NotNull] IValueProvider valueProvider,
|
IValueProvider valueProvider,
|
||||||
[NotNull] params Expression<Func<TModel, object>>[] includeExpressions)
|
params Expression<Func<TModel, object>>[] includeExpressions)
|
||||||
where TModel : class
|
where TModel : class
|
||||||
{
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (valueProvider == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(valueProvider));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (includeExpressions == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(includeExpressions));
|
||||||
|
}
|
||||||
|
|
||||||
if (BindingContext == null)
|
if (BindingContext == null)
|
||||||
{
|
{
|
||||||
var message = Resources.FormatPropertyOfTypeCannotBeNull(
|
var message = Resources.FormatPropertyOfTypeCannotBeNull(
|
||||||
|
|
@ -1364,12 +1479,27 @@ namespace Microsoft.AspNet.Mvc
|
||||||
/// <returns>A <see cref="Task"/> that on completion returns <c>true</c> if the update is successful.</returns>
|
/// <returns>A <see cref="Task"/> that on completion returns <c>true</c> if the update is successful.</returns>
|
||||||
[NonAction]
|
[NonAction]
|
||||||
public Task<bool> TryUpdateModelAsync<TModel>(
|
public Task<bool> TryUpdateModelAsync<TModel>(
|
||||||
[NotNull] TModel model,
|
TModel model,
|
||||||
string prefix,
|
string prefix,
|
||||||
[NotNull] IValueProvider valueProvider,
|
IValueProvider valueProvider,
|
||||||
[NotNull] Func<ModelBindingContext, string, bool> predicate)
|
Func<ModelBindingContext, string, bool> predicate)
|
||||||
where TModel : class
|
where TModel : class
|
||||||
{
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (valueProvider == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(valueProvider));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (predicate == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(predicate));
|
||||||
|
}
|
||||||
|
|
||||||
if (BindingContext == null)
|
if (BindingContext == null)
|
||||||
{
|
{
|
||||||
var message = Resources.FormatPropertyOfTypeCannotBeNull(
|
var message = Resources.FormatPropertyOfTypeCannotBeNull(
|
||||||
|
|
@ -1403,10 +1533,20 @@ namespace Microsoft.AspNet.Mvc
|
||||||
/// <returns>A <see cref="Task"/> that on completion returns <c>true</c> if the update is successful.</returns>
|
/// <returns>A <see cref="Task"/> that on completion returns <c>true</c> if the update is successful.</returns>
|
||||||
[NonAction]
|
[NonAction]
|
||||||
public virtual Task<bool> TryUpdateModelAsync(
|
public virtual Task<bool> TryUpdateModelAsync(
|
||||||
[NotNull] object model,
|
object model,
|
||||||
[NotNull] Type modelType,
|
Type modelType,
|
||||||
string prefix)
|
string prefix)
|
||||||
{
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (modelType == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(modelType));
|
||||||
|
}
|
||||||
|
|
||||||
if (BindingContext == null)
|
if (BindingContext == null)
|
||||||
{
|
{
|
||||||
var message = Resources.FormatPropertyOfTypeCannotBeNull(
|
var message = Resources.FormatPropertyOfTypeCannotBeNull(
|
||||||
|
|
@ -1442,12 +1582,32 @@ namespace Microsoft.AspNet.Mvc
|
||||||
/// <returns>A <see cref="Task"/> that on completion returns <c>true</c> if the update is successful.</returns>
|
/// <returns>A <see cref="Task"/> that on completion returns <c>true</c> if the update is successful.</returns>
|
||||||
[NonAction]
|
[NonAction]
|
||||||
public Task<bool> TryUpdateModelAsync(
|
public Task<bool> TryUpdateModelAsync(
|
||||||
[NotNull] object model,
|
object model,
|
||||||
[NotNull] Type modelType,
|
Type modelType,
|
||||||
string prefix,
|
string prefix,
|
||||||
[NotNull] IValueProvider valueProvider,
|
IValueProvider valueProvider,
|
||||||
[NotNull] Func<ModelBindingContext, string, bool> predicate)
|
Func<ModelBindingContext, string, bool> predicate)
|
||||||
{
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (modelType == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(modelType));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (valueProvider == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(valueProvider));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (predicate == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(predicate));
|
||||||
|
}
|
||||||
|
|
||||||
if (BindingContext == null)
|
if (BindingContext == null)
|
||||||
{
|
{
|
||||||
var message = Resources.FormatPropertyOfTypeCannotBeNull(
|
var message = Resources.FormatPropertyOfTypeCannotBeNull(
|
||||||
|
|
@ -1478,8 +1638,13 @@ namespace Microsoft.AspNet.Mvc
|
||||||
/// <returns><c>true</c> if the <see cref="ModelState"/> is valid; <c>false</c> otherwise.</returns>
|
/// <returns><c>true</c> if the <see cref="ModelState"/> is valid; <c>false</c> otherwise.</returns>
|
||||||
[NonAction]
|
[NonAction]
|
||||||
public virtual bool TryValidateModel(
|
public virtual bool TryValidateModel(
|
||||||
[NotNull] object model)
|
object model)
|
||||||
{
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
|
||||||
return TryValidateModel(model, prefix: null);
|
return TryValidateModel(model, prefix: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1492,9 +1657,14 @@ namespace Microsoft.AspNet.Mvc
|
||||||
/// <returns><c>true</c> if the <see cref="ModelState"/> is valid;<c>false</c> otherwise.</returns>
|
/// <returns><c>true</c> if the <see cref="ModelState"/> is valid;<c>false</c> otherwise.</returns>
|
||||||
[NonAction]
|
[NonAction]
|
||||||
public virtual bool TryValidateModel(
|
public virtual bool TryValidateModel(
|
||||||
[NotNull] object model,
|
object model,
|
||||||
string prefix)
|
string prefix)
|
||||||
{
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
|
||||||
if (BindingContext == null)
|
if (BindingContext == null)
|
||||||
{
|
{
|
||||||
var message = Resources.FormatPropertyOfTypeCannotBeNull(
|
var message = Resources.FormatPropertyOfTypeCannotBeNull(
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using Microsoft.AspNet.Mvc;
|
using Microsoft.AspNet.Mvc;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.Framework.DependencyInjection
|
namespace Microsoft.Framework.DependencyInjection
|
||||||
{
|
{
|
||||||
|
|
@ -18,9 +17,19 @@ namespace Microsoft.Framework.DependencyInjection
|
||||||
/// <param name="builder">The <see cref="IMvcBuilder"/>.</param>
|
/// <param name="builder">The <see cref="IMvcBuilder"/>.</param>
|
||||||
/// <param name="setupAction">The <see cref="MvcViewOptions"/> which need to be configured.</param>
|
/// <param name="setupAction">The <see cref="MvcViewOptions"/> which need to be configured.</param>
|
||||||
public static IMvcBuilder AddViewOptions(
|
public static IMvcBuilder AddViewOptions(
|
||||||
[NotNull] this IMvcBuilder builder,
|
this IMvcBuilder builder,
|
||||||
[NotNull] Action<MvcViewOptions> setupAction)
|
Action<MvcViewOptions> setupAction)
|
||||||
{
|
{
|
||||||
|
if (builder == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(builder));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setupAction == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(setupAction));
|
||||||
|
}
|
||||||
|
|
||||||
builder.Services.Configure(setupAction);
|
builder.Services.Configure(setupAction);
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
@ -11,24 +11,38 @@ using Microsoft.AspNet.Mvc.ViewEngines;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
using Microsoft.AspNet.Mvc.ViewFeatures;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures.Internal;
|
using Microsoft.AspNet.Mvc.ViewFeatures.Internal;
|
||||||
using Microsoft.Framework.DependencyInjection.Extensions;
|
using Microsoft.Framework.DependencyInjection.Extensions;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
using Microsoft.Framework.OptionsModel;
|
using Microsoft.Framework.OptionsModel;
|
||||||
|
|
||||||
namespace Microsoft.Framework.DependencyInjection
|
namespace Microsoft.Framework.DependencyInjection
|
||||||
{
|
{
|
||||||
public static class MvcViewFeaturesMvcCoreBuilderExtensions
|
public static class MvcViewFeaturesMvcCoreBuilderExtensions
|
||||||
{
|
{
|
||||||
public static IMvcCoreBuilder AddViews([NotNull] this IMvcCoreBuilder builder)
|
public static IMvcCoreBuilder AddViews(this IMvcCoreBuilder builder)
|
||||||
{
|
{
|
||||||
|
if (builder == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(builder));
|
||||||
|
}
|
||||||
|
|
||||||
builder.AddDataAnnotations();
|
builder.AddDataAnnotations();
|
||||||
AddViewServices(builder.Services);
|
AddViewServices(builder.Services);
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IMvcCoreBuilder AddViews(
|
public static IMvcCoreBuilder AddViews(
|
||||||
[NotNull] this IMvcCoreBuilder builder,
|
this IMvcCoreBuilder builder,
|
||||||
[NotNull] Action<MvcViewOptions> setupAction)
|
Action<MvcViewOptions> setupAction)
|
||||||
{
|
{
|
||||||
|
if (builder == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(builder));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setupAction == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(setupAction));
|
||||||
|
}
|
||||||
|
|
||||||
builder.AddDataAnnotations();
|
builder.AddDataAnnotations();
|
||||||
AddViewServices(builder.Services);
|
AddViewServices(builder.Services);
|
||||||
|
|
||||||
|
|
@ -41,9 +55,19 @@ namespace Microsoft.Framework.DependencyInjection
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IMvcCoreBuilder ConfigureViews(
|
public static IMvcCoreBuilder ConfigureViews(
|
||||||
[NotNull] this IMvcCoreBuilder builder,
|
this IMvcCoreBuilder builder,
|
||||||
[NotNull] Action<MvcViewOptions> setupAction)
|
Action<MvcViewOptions> setupAction)
|
||||||
{
|
{
|
||||||
|
if (builder == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(builder));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setupAction == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(setupAction));
|
||||||
|
}
|
||||||
|
|
||||||
builder.Services.Configure(setupAction);
|
builder.Services.Configure(setupAction);
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Mvc.ViewComponents;
|
using Microsoft.AspNet.Mvc.ViewComponents;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc
|
namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
|
|
@ -16,7 +15,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
/// Executes the result of a <see cref="ViewComponent"/> using the specified <paramref name="context"/>.
|
/// Executes the result of a <see cref="ViewComponent"/> using the specified <paramref name="context"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="context">The <see cref="ViewComponentContext"/> for the current component execution.</param>
|
/// <param name="context">The <see cref="ViewComponentContext"/> for the current component execution.</param>
|
||||||
void Execute([NotNull] ViewComponentContext context);
|
void Execute(ViewComponentContext context);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Asynchronously executes the result of a <see cref="ViewComponent"/> using the specified
|
/// Asynchronously executes the result of a <see cref="ViewComponent"/> using the specified
|
||||||
|
|
@ -24,6 +23,6 @@ namespace Microsoft.AspNet.Mvc
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="context">The <see cref="ViewComponentContext"/> for the current component execution.</param>
|
/// <param name="context">The <see cref="ViewComponentContext"/> for the current component execution.</param>
|
||||||
/// <returns>A <see cref="Task"/> that represents the asynchronous execution.</returns>
|
/// <returns>A <see cref="Task"/> that represents the asynchronous execution.</returns>
|
||||||
Task ExecuteAsync([NotNull] ViewComponentContext context);
|
Task ExecuteAsync(ViewComponentContext context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,11 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using Microsoft.AspNet.Mvc.Rendering;
|
using Microsoft.AspNet.Mvc.Rendering;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewFeatures.Internal
|
namespace Microsoft.AspNet.Mvc.ViewFeatures.Internal
|
||||||
{
|
{
|
||||||
public interface ICanHasViewContext
|
public interface ICanHasViewContext
|
||||||
{
|
{
|
||||||
void Contextualize([NotNull] ViewContext viewContext);
|
void Contextualize(ViewContext viewContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Mvc.Rendering;
|
using Microsoft.AspNet.Mvc.Rendering;
|
||||||
using Microsoft.AspNet.Mvc.ViewEngines;
|
using Microsoft.AspNet.Mvc.ViewEngines;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewFeatures.Internal
|
namespace Microsoft.AspNet.Mvc.ViewFeatures.Internal
|
||||||
{
|
{
|
||||||
|
|
@ -14,8 +14,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures.Internal
|
||||||
|
|
||||||
public string Path => string.Empty;
|
public string Path => string.Empty;
|
||||||
|
|
||||||
public Task RenderAsync([NotNull] ViewContext context)
|
public Task RenderAsync(ViewContext context)
|
||||||
{
|
{
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(context));
|
||||||
|
}
|
||||||
|
|
||||||
return Task.FromResult(0);
|
return Task.FromResult(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,6 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.AspNet.Mvc.ModelBinding;
|
using Microsoft.AspNet.Mvc.ModelBinding;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewFeatures.Internal
|
namespace Microsoft.AspNet.Mvc.ViewFeatures.Internal
|
||||||
{
|
{
|
||||||
|
|
@ -62,8 +60,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures.Internal
|
||||||
{
|
{
|
||||||
private Dictionary<string, int> _ordering = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
|
private Dictionary<string, int> _ordering = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
public ErrorsOrderer([NotNull] ModelMetadata metadata)
|
public ErrorsOrderer(ModelMetadata metadata)
|
||||||
{
|
{
|
||||||
|
if (metadata == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(metadata));
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var data in metadata.Properties)
|
foreach (var data in metadata.Properties)
|
||||||
{
|
{
|
||||||
_ordering[data.PropertyName] = data.Order;
|
_ordering[data.PropertyName] = data.Order;
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,11 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.AspNet.Mvc.ModelBinding.Validation;
|
using Microsoft.AspNet.Mvc.ModelBinding.Validation;
|
||||||
using Microsoft.AspNet.Mvc.Rendering;
|
|
||||||
using Microsoft.AspNet.Mvc.ViewEngines;
|
using Microsoft.AspNet.Mvc.ViewEngines;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
using Microsoft.AspNet.Mvc.ViewFeatures;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc
|
namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
|
|
@ -15,10 +14,24 @@ namespace Microsoft.AspNet.Mvc
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class MvcViewOptions
|
public class MvcViewOptions
|
||||||
{
|
{
|
||||||
|
private HtmlHelperOptions _htmlHelperOptions = new HtmlHelperOptions();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets programmatic configuration for the HTML helpers and <see cref="ViewContext"/>.
|
/// Gets or sets programmatic configuration for the HTML helpers and <see cref="Rendering.ViewContext"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public HtmlHelperOptions HtmlHelperOptions { get;[param: NotNull] set; } = new HtmlHelperOptions();
|
public HtmlHelperOptions HtmlHelperOptions
|
||||||
|
{
|
||||||
|
get { return _htmlHelperOptions; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
_htmlHelperOptions = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a list <see cref="IViewEngine"/>s used by this application.
|
/// Gets a list <see cref="IViewEngine"/>s used by this application.
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.Framework.DependencyInjection;
|
using Microsoft.Framework.DependencyInjection;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
using Microsoft.Framework.Logging;
|
using Microsoft.Framework.Logging;
|
||||||
using Microsoft.Net.Http.Headers;
|
using Microsoft.Net.Http.Headers;
|
||||||
using Microsoft.Framework.OptionsModel;
|
using Microsoft.Framework.OptionsModel;
|
||||||
|
|
@ -54,8 +53,13 @@ namespace Microsoft.AspNet.Mvc
|
||||||
public MediaTypeHeaderValue ContentType { get; set; }
|
public MediaTypeHeaderValue ContentType { get; set; }
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override async Task ExecuteResultAsync([NotNull] ActionContext context)
|
public override async Task ExecuteResultAsync(ActionContext context)
|
||||||
{
|
{
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(context));
|
||||||
|
}
|
||||||
|
|
||||||
var viewEngine = ViewEngine ??
|
var viewEngine = ViewEngine ??
|
||||||
context.HttpContext.RequestServices.GetRequiredService<ICompositeViewEngine>();
|
context.HttpContext.RequestServices.GetRequiredService<ICompositeViewEngine>();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ using Microsoft.AspNet.Mvc.Internal;
|
||||||
using Microsoft.AspNet.Mvc.ModelBinding.Validation;
|
using Microsoft.AspNet.Mvc.ModelBinding.Validation;
|
||||||
using Microsoft.AspNet.Routing;
|
using Microsoft.AspNet.Routing;
|
||||||
using Microsoft.Framework.DependencyInjection;
|
using Microsoft.Framework.DependencyInjection;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
using Microsoft.AspNet.Mvc.Routing;
|
using Microsoft.AspNet.Mvc.Routing;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc
|
namespace Microsoft.AspNet.Mvc
|
||||||
|
|
@ -192,8 +191,13 @@ namespace Microsoft.AspNet.Mvc
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="context">The <see cref="ClientModelValidationContext"/> used to generate the URL.</param>
|
/// <param name="context">The <see cref="ClientModelValidationContext"/> used to generate the URL.</param>
|
||||||
/// <returns>The URL where the client should send a validation request.</returns>
|
/// <returns>The URL where the client should send a validation request.</returns>
|
||||||
protected virtual string GetUrl([NotNull] ClientModelValidationContext context)
|
protected virtual string GetUrl(ClientModelValidationContext context)
|
||||||
{
|
{
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(context));
|
||||||
|
}
|
||||||
|
|
||||||
var urlHelper = context.RequestServices.GetRequiredService<IUrlHelper>();
|
var urlHelper = context.RequestServices.GetRequiredService<IUrlHelper>();
|
||||||
var url = urlHelper.RouteUrl(new UrlRouteContext()
|
var url = urlHelper.RouteUrl(new UrlRouteContext()
|
||||||
{
|
{
|
||||||
|
|
@ -230,8 +234,13 @@ namespace Microsoft.AspNet.Mvc
|
||||||
/// Thrown if unable to generate a target URL for a validation request.
|
/// Thrown if unable to generate a target URL for a validation request.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
public virtual IEnumerable<ModelClientValidationRule> GetClientValidationRules(
|
public virtual IEnumerable<ModelClientValidationRule> GetClientValidationRules(
|
||||||
[NotNull] ClientModelValidationContext context)
|
ClientModelValidationContext context)
|
||||||
{
|
{
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(context));
|
||||||
|
}
|
||||||
|
|
||||||
var metadata = context.ModelMetadata;
|
var metadata = context.ModelMetadata;
|
||||||
var rule = new ModelClientValidationRemoteRule(
|
var rule = new ModelClientValidationRemoteRule(
|
||||||
FormatErrorMessage(metadata.GetDisplayName()),
|
FormatErrorMessage(metadata.GetDisplayName()),
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using Microsoft.AspNet.Html.Abstractions;
|
using Microsoft.AspNet.Html.Abstractions;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.Rendering
|
namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
{
|
{
|
||||||
|
|
@ -37,8 +36,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// case-sensitive file systems.
|
/// case-sensitive file systems.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent Display([NotNull] this IHtmlHelper htmlHelper, string expression)
|
public static IHtmlContent Display(this IHtmlHelper htmlHelper, string expression)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.Display(expression, templateName: null, htmlFieldName: null, additionalViewData: null);
|
return htmlHelper.Display(expression, templateName: null, htmlFieldName: null, additionalViewData: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -73,10 +77,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent Display(
|
public static IHtmlContent Display(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string expression,
|
string expression,
|
||||||
object additionalViewData)
|
object additionalViewData)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.Display(
|
return htmlHelper.Display(
|
||||||
expression,
|
expression,
|
||||||
templateName: null,
|
templateName: null,
|
||||||
|
|
@ -111,10 +120,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent Display(
|
public static IHtmlContent Display(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string expression,
|
string expression,
|
||||||
string templateName)
|
string templateName)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.Display(expression, templateName, htmlFieldName: null, additionalViewData: null);
|
return htmlHelper.Display(expression, templateName, htmlFieldName: null, additionalViewData: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -150,11 +164,16 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent Display(
|
public static IHtmlContent Display(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string expression,
|
string expression,
|
||||||
string templateName,
|
string templateName,
|
||||||
object additionalViewData)
|
object additionalViewData)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.Display(
|
return htmlHelper.Display(
|
||||||
expression,
|
expression,
|
||||||
templateName,
|
templateName,
|
||||||
|
|
@ -193,11 +212,16 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent Display(
|
public static IHtmlContent Display(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string expression,
|
string expression,
|
||||||
string templateName,
|
string templateName,
|
||||||
string htmlFieldName)
|
string htmlFieldName)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.Display(expression, templateName, htmlFieldName, additionalViewData: null);
|
return htmlHelper.Display(expression, templateName, htmlFieldName, additionalViewData: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -221,9 +245,19 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent DisplayFor<TModel, TResult>(
|
public static IHtmlContent DisplayFor<TModel, TResult>(
|
||||||
[NotNull] this IHtmlHelper<TModel> htmlHelper,
|
this IHtmlHelper<TModel> htmlHelper,
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression)
|
Expression<Func<TModel, TResult>> expression)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.DisplayFor<TResult>(
|
return htmlHelper.DisplayFor<TResult>(
|
||||||
expression,
|
expression,
|
||||||
templateName: null,
|
templateName: null,
|
||||||
|
|
@ -257,10 +291,20 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent DisplayFor<TModel, TResult>(
|
public static IHtmlContent DisplayFor<TModel, TResult>(
|
||||||
[NotNull] this IHtmlHelper<TModel> htmlHelper,
|
this IHtmlHelper<TModel> htmlHelper,
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
object additionalViewData)
|
object additionalViewData)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.DisplayFor<TResult>(
|
return htmlHelper.DisplayFor<TResult>(
|
||||||
expression,
|
expression,
|
||||||
templateName: null,
|
templateName: null,
|
||||||
|
|
@ -290,10 +334,20 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent DisplayFor<TModel, TResult>(
|
public static IHtmlContent DisplayFor<TModel, TResult>(
|
||||||
[NotNull] this IHtmlHelper<TModel> htmlHelper,
|
this IHtmlHelper<TModel> htmlHelper,
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
string templateName)
|
string templateName)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.DisplayFor<TResult>(
|
return htmlHelper.DisplayFor<TResult>(
|
||||||
expression,
|
expression,
|
||||||
templateName,
|
templateName,
|
||||||
|
|
@ -328,11 +382,21 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent DisplayFor<TModel, TResult>(
|
public static IHtmlContent DisplayFor<TModel, TResult>(
|
||||||
[NotNull] this IHtmlHelper<TModel> htmlHelper,
|
this IHtmlHelper<TModel> htmlHelper,
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
string templateName,
|
string templateName,
|
||||||
object additionalViewData)
|
object additionalViewData)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.DisplayFor<TResult>(
|
return htmlHelper.DisplayFor<TResult>(
|
||||||
expression,
|
expression,
|
||||||
templateName,
|
templateName,
|
||||||
|
|
@ -366,11 +430,21 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent DisplayFor<TModel, TResult>(
|
public static IHtmlContent DisplayFor<TModel, TResult>(
|
||||||
[NotNull] this IHtmlHelper<TModel> htmlHelper,
|
this IHtmlHelper<TModel> htmlHelper,
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
string templateName,
|
string templateName,
|
||||||
string htmlFieldName)
|
string htmlFieldName)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.DisplayFor<TResult>(
|
return htmlHelper.DisplayFor<TResult>(
|
||||||
expression,
|
expression,
|
||||||
templateName: templateName,
|
templateName: templateName,
|
||||||
|
|
@ -394,8 +468,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// case-sensitive file systems.
|
/// case-sensitive file systems.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent DisplayForModel([NotNull] this IHtmlHelper htmlHelper)
|
public static IHtmlContent DisplayForModel(this IHtmlHelper htmlHelper)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.Display(
|
return htmlHelper.Display(
|
||||||
expression: null,
|
expression: null,
|
||||||
templateName: null,
|
templateName: null,
|
||||||
|
|
@ -424,8 +503,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// case-sensitive file systems.
|
/// case-sensitive file systems.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent DisplayForModel([NotNull] this IHtmlHelper htmlHelper, object additionalViewData)
|
public static IHtmlContent DisplayForModel(this IHtmlHelper htmlHelper, object additionalViewData)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.Display(
|
return htmlHelper.Display(
|
||||||
expression: null,
|
expression: null,
|
||||||
templateName: null,
|
templateName: null,
|
||||||
|
|
@ -450,8 +534,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// case-sensitive file systems.
|
/// case-sensitive file systems.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent DisplayForModel([NotNull] this IHtmlHelper htmlHelper, string templateName)
|
public static IHtmlContent DisplayForModel(this IHtmlHelper htmlHelper, string templateName)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.Display(
|
return htmlHelper.Display(
|
||||||
expression: null,
|
expression: null,
|
||||||
templateName: templateName,
|
templateName: templateName,
|
||||||
|
|
@ -483,10 +572,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent DisplayForModel(
|
public static IHtmlContent DisplayForModel(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string templateName,
|
string templateName,
|
||||||
object additionalViewData)
|
object additionalViewData)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.Display(
|
return htmlHelper.Display(
|
||||||
expression: null,
|
expression: null,
|
||||||
templateName: templateName,
|
templateName: templateName,
|
||||||
|
|
@ -517,10 +611,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent DisplayForModel(
|
public static IHtmlContent DisplayForModel(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string templateName,
|
string templateName,
|
||||||
string htmlFieldName)
|
string htmlFieldName)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.Display(
|
return htmlHelper.Display(
|
||||||
expression: null,
|
expression: null,
|
||||||
templateName: templateName,
|
templateName: templateName,
|
||||||
|
|
@ -556,11 +655,16 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent DisplayForModel(
|
public static IHtmlContent DisplayForModel(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string templateName,
|
string templateName,
|
||||||
string htmlFieldName,
|
string htmlFieldName,
|
||||||
object additionalViewData)
|
object additionalViewData)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.Display(
|
return htmlHelper.Display(
|
||||||
expression: null,
|
expression: null,
|
||||||
templateName: templateName,
|
templateName: templateName,
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.Rendering
|
namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
{
|
{
|
||||||
|
|
@ -19,8 +17,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
|
/// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
|
||||||
/// <returns>A <see cref="string"/> containing the display name.</returns>
|
/// <returns>A <see cref="string"/> containing the display name.</returns>
|
||||||
public static string DisplayNameForModel([NotNull] this IHtmlHelper htmlHelper)
|
public static string DisplayNameForModel(this IHtmlHelper htmlHelper)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.DisplayName(expression: null);
|
return htmlHelper.DisplayName(expression: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -36,9 +39,19 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
|
/// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
|
||||||
/// <returns>A <see cref="string"/> containing the display name.</returns>
|
/// <returns>A <see cref="string"/> containing the display name.</returns>
|
||||||
public static string DisplayNameFor<TModelItem, TResult>(
|
public static string DisplayNameFor<TModelItem, TResult>(
|
||||||
[NotNull] this IHtmlHelper<IEnumerable<TModelItem>> htmlHelper,
|
this IHtmlHelper<IEnumerable<TModelItem>> htmlHelper,
|
||||||
[NotNull] Expression<Func<TModelItem, TResult>> expression)
|
Expression<Func<TModelItem, TResult>> expression)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.DisplayNameForInnerType<TModelItem, TResult>(expression);
|
return htmlHelper.DisplayNameForInnerType<TModelItem, TResult>(expression);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using Microsoft.AspNet.Html.Abstractions;
|
using Microsoft.AspNet.Html.Abstractions;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.Rendering
|
namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
{
|
{
|
||||||
|
|
@ -38,8 +36,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// case-sensitive file systems.
|
/// case-sensitive file systems.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent Editor([NotNull] this IHtmlHelper htmlHelper, string expression)
|
public static IHtmlContent Editor(this IHtmlHelper htmlHelper, string expression)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.Editor(expression, templateName: null, htmlFieldName: null, additionalViewData: null);
|
return htmlHelper.Editor(expression, templateName: null, htmlFieldName: null, additionalViewData: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -55,8 +58,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <param name="additionalViewData">
|
/// <param name="additionalViewData">
|
||||||
/// An anonymous <see cref="object"/> or <see cref="System.Collections.Generic.IDictionary{string, object}"/>
|
/// An anonymous <see cref="object"/> or <see cref="System.Collections.Generic.IDictionary{string, object}"/>
|
||||||
/// that can contain additional view data that will be merged into the <see cref="ViewDataDictionary{TModel}"/>
|
/// that can contain additional view data that will be merged into the
|
||||||
/// instance created for the template.
|
/// <see cref="ViewFeatures.ViewDataDictionary{TModel}"/> instance created for the template.
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element(s).</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element(s).</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
|
|
@ -74,10 +77,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent Editor(
|
public static IHtmlContent Editor(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string expression,
|
string expression,
|
||||||
object additionalViewData)
|
object additionalViewData)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.Editor(
|
return htmlHelper.Editor(
|
||||||
expression,
|
expression,
|
||||||
templateName: null,
|
templateName: null,
|
||||||
|
|
@ -111,8 +119,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// case-sensitive file systems.
|
/// case-sensitive file systems.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent Editor([NotNull] this IHtmlHelper htmlHelper, string expression, string templateName)
|
public static IHtmlContent Editor(this IHtmlHelper htmlHelper, string expression, string templateName)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.Editor(expression, templateName, htmlFieldName: null, additionalViewData: null);
|
return htmlHelper.Editor(expression, templateName, htmlFieldName: null, additionalViewData: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -129,8 +142,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <param name="templateName">The name of the template used to create the HTML markup.</param>
|
/// <param name="templateName">The name of the template used to create the HTML markup.</param>
|
||||||
/// <param name="additionalViewData">
|
/// <param name="additionalViewData">
|
||||||
/// An anonymous <see cref="object"/> or <see cref="System.Collections.Generic.IDictionary{string, object}"/>
|
/// An anonymous <see cref="object"/> or <see cref="System.Collections.Generic.IDictionary{string, object}"/>
|
||||||
/// that can contain additional view data that will be merged into the <see cref="ViewDataDictionary{TModel}"/>
|
/// that can contain additional view data that will be merged into the
|
||||||
/// instance created for the template.
|
/// <see cref="ViewFeatures.ViewDataDictionary{TModel}"/> instance created for the template.
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element(s).</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element(s).</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
|
|
@ -148,11 +161,16 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent Editor(
|
public static IHtmlContent Editor(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string expression,
|
string expression,
|
||||||
string templateName,
|
string templateName,
|
||||||
object additionalViewData)
|
object additionalViewData)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.Editor(
|
return htmlHelper.Editor(
|
||||||
expression,
|
expression,
|
||||||
templateName,
|
templateName,
|
||||||
|
|
@ -191,11 +209,16 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent Editor(
|
public static IHtmlContent Editor(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string expression,
|
string expression,
|
||||||
string templateName,
|
string templateName,
|
||||||
string htmlFieldName)
|
string htmlFieldName)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.Editor(expression, templateName, htmlFieldName, additionalViewData: null);
|
return htmlHelper.Editor(expression, templateName, htmlFieldName, additionalViewData: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -219,9 +242,19 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent EditorFor<TModel, TResult>(
|
public static IHtmlContent EditorFor<TModel, TResult>(
|
||||||
[NotNull] this IHtmlHelper<TModel> htmlHelper,
|
this IHtmlHelper<TModel> htmlHelper,
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression)
|
Expression<Func<TModel, TResult>> expression)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.EditorFor(expression, templateName: null, htmlFieldName: null, additionalViewData: null);
|
return htmlHelper.EditorFor(expression, templateName: null, htmlFieldName: null, additionalViewData: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -234,8 +267,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <param name="expression">An expression to be evaluated against the current model.</param>
|
/// <param name="expression">An expression to be evaluated against the current model.</param>
|
||||||
/// <param name="additionalViewData">
|
/// <param name="additionalViewData">
|
||||||
/// An anonymous <see cref="object"/> or <see cref="System.Collections.Generic.IDictionary{string, object}"/>
|
/// An anonymous <see cref="object"/> or <see cref="System.Collections.Generic.IDictionary{string, object}"/>
|
||||||
/// that can contain additional view data that will be merged into the <see cref="ViewDataDictionary{TModel}"/>
|
/// that can contain additional view data that will be merged into the
|
||||||
/// instance created for the template.
|
/// <see cref="ViewFeatures.ViewDataDictionary{TModel}"/> instance created for the template.
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <typeparam name="TModel">The type of the model.</typeparam>
|
/// <typeparam name="TModel">The type of the model.</typeparam>
|
||||||
/// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
|
/// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
|
||||||
|
|
@ -251,10 +284,20 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent EditorFor<TModel, TResult>(
|
public static IHtmlContent EditorFor<TModel, TResult>(
|
||||||
[NotNull] this IHtmlHelper<TModel> htmlHelper,
|
this IHtmlHelper<TModel> htmlHelper,
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
object additionalViewData)
|
object additionalViewData)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.EditorFor(
|
return htmlHelper.EditorFor(
|
||||||
expression,
|
expression,
|
||||||
templateName: null,
|
templateName: null,
|
||||||
|
|
@ -284,10 +327,20 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent EditorFor<TModel, TResult>(
|
public static IHtmlContent EditorFor<TModel, TResult>(
|
||||||
[NotNull] this IHtmlHelper<TModel> htmlHelper,
|
this IHtmlHelper<TModel> htmlHelper,
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
string templateName)
|
string templateName)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.EditorFor(expression, templateName, htmlFieldName: null, additionalViewData: null);
|
return htmlHelper.EditorFor(expression, templateName, htmlFieldName: null, additionalViewData: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -301,8 +354,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <param name="templateName">The name of the template that is used to create the HTML markup.</param>
|
/// <param name="templateName">The name of the template that is used to create the HTML markup.</param>
|
||||||
/// <param name="additionalViewData">
|
/// <param name="additionalViewData">
|
||||||
/// An anonymous <see cref="object"/> or <see cref="System.Collections.Generic.IDictionary{string, object}"/>
|
/// An anonymous <see cref="object"/> or <see cref="System.Collections.Generic.IDictionary{string, object}"/>
|
||||||
/// that can contain additional view data that will be merged into the <see cref="ViewDataDictionary{TModel}"/>
|
/// that can contain additional view data that will be merged into the
|
||||||
/// instance created for the template.
|
/// <see cref="ViewFeatures.ViewDataDictionary{TModel}"/> instance created for the template.
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <typeparam name="TModel">The type of the model.</typeparam>
|
/// <typeparam name="TModel">The type of the model.</typeparam>
|
||||||
/// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
|
/// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
|
||||||
|
|
@ -318,11 +371,21 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent EditorFor<TModel, TResult>(
|
public static IHtmlContent EditorFor<TModel, TResult>(
|
||||||
[NotNull] this IHtmlHelper<TModel> htmlHelper,
|
this IHtmlHelper<TModel> htmlHelper,
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
string templateName,
|
string templateName,
|
||||||
object additionalViewData)
|
object additionalViewData)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.EditorFor(
|
return htmlHelper.EditorFor(
|
||||||
expression,
|
expression,
|
||||||
templateName,
|
templateName,
|
||||||
|
|
@ -356,11 +419,21 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent EditorFor<TModel, TResult>(
|
public static IHtmlContent EditorFor<TModel, TResult>(
|
||||||
[NotNull] this IHtmlHelper<TModel> htmlHelper,
|
this IHtmlHelper<TModel> htmlHelper,
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
string templateName,
|
string templateName,
|
||||||
string htmlFieldName)
|
string htmlFieldName)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.EditorFor(expression, templateName, htmlFieldName, additionalViewData: null);
|
return htmlHelper.EditorFor(expression, templateName, htmlFieldName, additionalViewData: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -380,8 +453,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// case-sensitive file systems.
|
/// case-sensitive file systems.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent EditorForModel([NotNull] this IHtmlHelper htmlHelper)
|
public static IHtmlContent EditorForModel(this IHtmlHelper htmlHelper)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.Editor(
|
return htmlHelper.Editor(
|
||||||
expression: null,
|
expression: null,
|
||||||
templateName: null,
|
templateName: null,
|
||||||
|
|
@ -396,8 +474,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
|
/// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
|
||||||
/// <param name="additionalViewData">
|
/// <param name="additionalViewData">
|
||||||
/// An anonymous <see cref="object"/> or <see cref="System.Collections.Generic.IDictionary{string, object}"/>
|
/// An anonymous <see cref="object"/> or <see cref="System.Collections.Generic.IDictionary{string, object}"/>
|
||||||
/// that can contain additional view data that will be merged into the <see cref="ViewDataDictionary{TModel}"/>
|
/// that can contain additional view data that will be merged into the
|
||||||
/// instance created for the template.
|
/// <see cref="ViewFeatures.ViewDataDictionary{TModel}"/> instance created for the template.
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element(s).</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element(s).</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
|
|
@ -410,8 +488,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// case-sensitive file systems.
|
/// case-sensitive file systems.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent EditorForModel([NotNull] this IHtmlHelper htmlHelper, object additionalViewData)
|
public static IHtmlContent EditorForModel(this IHtmlHelper htmlHelper, object additionalViewData)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.Editor(
|
return htmlHelper.Editor(
|
||||||
expression: null,
|
expression: null,
|
||||||
templateName: null,
|
templateName: null,
|
||||||
|
|
@ -436,8 +519,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// case-sensitive file systems.
|
/// case-sensitive file systems.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent EditorForModel([NotNull] this IHtmlHelper htmlHelper, string templateName)
|
public static IHtmlContent EditorForModel(this IHtmlHelper htmlHelper, string templateName)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.Editor(
|
return htmlHelper.Editor(
|
||||||
expression: null,
|
expression: null,
|
||||||
templateName: templateName,
|
templateName: templateName,
|
||||||
|
|
@ -454,8 +542,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <param name="templateName">The name of the template used to create the HTML markup.</param>
|
/// <param name="templateName">The name of the template used to create the HTML markup.</param>
|
||||||
/// <param name="additionalViewData">
|
/// <param name="additionalViewData">
|
||||||
/// An anonymous <see cref="object"/> or <see cref="System.Collections.Generic.IDictionary{string, object}"/>
|
/// An anonymous <see cref="object"/> or <see cref="System.Collections.Generic.IDictionary{string, object}"/>
|
||||||
/// that can contain additional view data that will be merged into the <see cref="ViewDataDictionary{TModel}"/>
|
/// that can contain additional view data that will be merged into the
|
||||||
/// instance created for the template.
|
/// <see cref="ViewFeatures.ViewDataDictionary{TModel}"/> instance created for the template.
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element(s).</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element(s).</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
|
|
@ -469,10 +557,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent EditorForModel(
|
public static IHtmlContent EditorForModel(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string templateName,
|
string templateName,
|
||||||
object additionalViewData)
|
object additionalViewData)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.Editor(
|
return htmlHelper.Editor(
|
||||||
expression: null,
|
expression: null,
|
||||||
templateName: templateName,
|
templateName: templateName,
|
||||||
|
|
@ -503,10 +596,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent EditorForModel(
|
public static IHtmlContent EditorForModel(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string templateName,
|
string templateName,
|
||||||
string htmlFieldName)
|
string htmlFieldName)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.Editor(
|
return htmlHelper.Editor(
|
||||||
expression: null,
|
expression: null,
|
||||||
templateName: templateName,
|
templateName: templateName,
|
||||||
|
|
@ -527,8 +625,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <param name="additionalViewData">
|
/// <param name="additionalViewData">
|
||||||
/// An anonymous <see cref="object"/> or <see cref="System.Collections.Generic.IDictionary{string, object}"/>
|
/// An anonymous <see cref="object"/> or <see cref="System.Collections.Generic.IDictionary{string, object}"/>
|
||||||
/// that can contain additional view data that will be merged into the <see cref="ViewDataDictionary{TModel}"/>
|
/// that can contain additional view data that will be merged into the
|
||||||
/// instance created for the template.
|
/// <see cref="ViewFeatures.ViewDataDictionary{TModel}"/> instance created for the template.
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element(s).</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element(s).</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
|
|
@ -542,11 +640,16 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent EditorForModel(
|
public static IHtmlContent EditorForModel(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string templateName,
|
string templateName,
|
||||||
string htmlFieldName,
|
string htmlFieldName,
|
||||||
object additionalViewData)
|
object additionalViewData)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.Editor(
|
return htmlHelper.Editor(
|
||||||
expression: null,
|
expression: null,
|
||||||
templateName: templateName,
|
templateName: templateName,
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
using System;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.Rendering
|
namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
{
|
{
|
||||||
|
|
@ -22,8 +21,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static MvcForm BeginForm([NotNull] this IHtmlHelper htmlHelper)
|
public static MvcForm BeginForm(this IHtmlHelper htmlHelper)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
// Generates <form action="{current url}" method="post">.
|
// Generates <form action="{current url}" method="post">.
|
||||||
return htmlHelper.BeginForm(actionName: null, controllerName: null, routeValues: null,
|
return htmlHelper.BeginForm(actionName: null, controllerName: null, routeValues: null,
|
||||||
method: FormMethod.Post, htmlAttributes: null);
|
method: FormMethod.Post, htmlAttributes: null);
|
||||||
|
|
@ -41,8 +45,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static MvcForm BeginForm([NotNull] this IHtmlHelper htmlHelper, FormMethod method)
|
public static MvcForm BeginForm(this IHtmlHelper htmlHelper, FormMethod method)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.BeginForm(actionName: null, controllerName: null, routeValues: null,
|
return htmlHelper.BeginForm(actionName: null, controllerName: null, routeValues: null,
|
||||||
method: method, htmlAttributes: null);
|
method: method, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
@ -65,10 +74,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static MvcForm BeginForm(
|
public static MvcForm BeginForm(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
FormMethod method,
|
FormMethod method,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.BeginForm(actionName: null, controllerName: null, routeValues: null,
|
return htmlHelper.BeginForm(actionName: null, controllerName: null, routeValues: null,
|
||||||
method: method, htmlAttributes: htmlAttributes);
|
method: method, htmlAttributes: htmlAttributes);
|
||||||
}
|
}
|
||||||
|
|
@ -91,8 +105,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static MvcForm BeginForm([NotNull] this IHtmlHelper htmlHelper, object routeValues)
|
public static MvcForm BeginForm(this IHtmlHelper htmlHelper, object routeValues)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.BeginForm(actionName: null, controllerName: null, routeValues: routeValues,
|
return htmlHelper.BeginForm(actionName: null, controllerName: null, routeValues: routeValues,
|
||||||
method: FormMethod.Post, htmlAttributes: null);
|
method: FormMethod.Post, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
@ -111,10 +130,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static MvcForm BeginForm(
|
public static MvcForm BeginForm(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string actionName,
|
string actionName,
|
||||||
string controllerName)
|
string controllerName)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.BeginForm(actionName, controllerName, routeValues: null,
|
return htmlHelper.BeginForm(actionName, controllerName, routeValues: null,
|
||||||
method: FormMethod.Post, htmlAttributes: null);
|
method: FormMethod.Post, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
@ -140,11 +164,16 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static MvcForm BeginForm(
|
public static MvcForm BeginForm(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string actionName,
|
string actionName,
|
||||||
string controllerName,
|
string controllerName,
|
||||||
object routeValues)
|
object routeValues)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.BeginForm(actionName, controllerName, routeValues,
|
return htmlHelper.BeginForm(actionName, controllerName, routeValues,
|
||||||
FormMethod.Post, htmlAttributes: null);
|
FormMethod.Post, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
@ -164,11 +193,16 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static MvcForm BeginForm(
|
public static MvcForm BeginForm(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string actionName,
|
string actionName,
|
||||||
string controllerName,
|
string controllerName,
|
||||||
FormMethod method)
|
FormMethod method)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.BeginForm(actionName, controllerName, routeValues: null,
|
return htmlHelper.BeginForm(actionName, controllerName, routeValues: null,
|
||||||
method: method, htmlAttributes: null);
|
method: method, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
@ -195,12 +229,17 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static MvcForm BeginForm(
|
public static MvcForm BeginForm(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string actionName,
|
string actionName,
|
||||||
string controllerName,
|
string controllerName,
|
||||||
object routeValues,
|
object routeValues,
|
||||||
FormMethod method)
|
FormMethod method)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.BeginForm(actionName, controllerName, routeValues,
|
return htmlHelper.BeginForm(actionName, controllerName, routeValues,
|
||||||
method, htmlAttributes: null);
|
method, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
@ -225,12 +264,17 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static MvcForm BeginForm(
|
public static MvcForm BeginForm(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string actionName,
|
string actionName,
|
||||||
string controllerName,
|
string controllerName,
|
||||||
FormMethod method,
|
FormMethod method,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.BeginForm(actionName, controllerName, routeValues: null,
|
return htmlHelper.BeginForm(actionName, controllerName, routeValues: null,
|
||||||
method: method, htmlAttributes: htmlAttributes);
|
method: method, htmlAttributes: htmlAttributes);
|
||||||
}
|
}
|
||||||
|
|
@ -253,8 +297,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static MvcForm BeginRouteForm([NotNull] this IHtmlHelper htmlHelper, object routeValues)
|
public static MvcForm BeginRouteForm(this IHtmlHelper htmlHelper, object routeValues)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.BeginRouteForm(
|
return htmlHelper.BeginRouteForm(
|
||||||
routeName: null,
|
routeName: null,
|
||||||
routeValues: routeValues,
|
routeValues: routeValues,
|
||||||
|
|
@ -274,8 +323,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static MvcForm BeginRouteForm([NotNull] this IHtmlHelper htmlHelper, string routeName)
|
public static MvcForm BeginRouteForm(this IHtmlHelper htmlHelper, string routeName)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.BeginRouteForm(
|
return htmlHelper.BeginRouteForm(
|
||||||
routeName,
|
routeName,
|
||||||
routeValues: null,
|
routeValues: null,
|
||||||
|
|
@ -303,10 +357,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static MvcForm BeginRouteForm(
|
public static MvcForm BeginRouteForm(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string routeName,
|
string routeName,
|
||||||
object routeValues)
|
object routeValues)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.BeginRouteForm(routeName, routeValues, FormMethod.Post, htmlAttributes: null);
|
return htmlHelper.BeginRouteForm(routeName, routeValues, FormMethod.Post, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -324,10 +383,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static MvcForm BeginRouteForm(
|
public static MvcForm BeginRouteForm(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string routeName,
|
string routeName,
|
||||||
FormMethod method)
|
FormMethod method)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.BeginRouteForm(routeName, routeValues: null, method: method, htmlAttributes: null);
|
return htmlHelper.BeginRouteForm(routeName, routeValues: null, method: method, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -352,11 +416,16 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static MvcForm BeginRouteForm(
|
public static MvcForm BeginRouteForm(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string routeName,
|
string routeName,
|
||||||
object routeValues,
|
object routeValues,
|
||||||
FormMethod method)
|
FormMethod method)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.BeginRouteForm(routeName, routeValues, method, htmlAttributes: null);
|
return htmlHelper.BeginRouteForm(routeName, routeValues, method, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -379,11 +448,16 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static MvcForm BeginRouteForm(
|
public static MvcForm BeginRouteForm(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string routeName,
|
string routeName,
|
||||||
FormMethod method,
|
FormMethod method,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.BeginRouteForm(
|
return htmlHelper.BeginRouteForm(
|
||||||
routeName,
|
routeName,
|
||||||
routeValues: null,
|
routeValues: null,
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using Microsoft.AspNet.Html.Abstractions;
|
using Microsoft.AspNet.Html.Abstractions;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.Rendering
|
namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
{
|
{
|
||||||
|
|
@ -23,8 +21,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> elements.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> elements.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set checkbox
|
/// Combines <see cref="ViewFeatures.TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
||||||
/// element's "name" attribute. Sanitizes <paramref name="expression"/> to set checkbox element's "id"
|
/// checkbox element's "name" attribute. Sanitizes <paramref name="expression"/> to set checkbox element's "id"
|
||||||
/// attribute.
|
/// attribute.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// <para>Determines checkbox element's "checked" attribute based on the following precedence:</para>
|
/// <para>Determines checkbox element's "checked" attribute based on the following precedence:</para>
|
||||||
|
|
@ -34,8 +32,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// fully-qualified name) if entry exists and can be converted to a <see cref="bool"/>.
|
/// fully-qualified name) if entry exists and can be converted to a <see cref="bool"/>.
|
||||||
/// </item>
|
/// </item>
|
||||||
/// <item>
|
/// <item>
|
||||||
/// <see cref="ViewDataDictionary"/> entry for <paramref name="expression"/> (converted to a fully-qualified
|
/// <see cref="ViewFeatures.ViewDataDictionary"/> entry for <paramref name="expression"/> (converted to a
|
||||||
/// name) if entry exists and can be converted to a <see cref="bool"/>.
|
/// fully-qualified name) if entry exists and can be converted to a <see cref="bool"/>.
|
||||||
/// </item>
|
/// </item>
|
||||||
/// <item>
|
/// <item>
|
||||||
/// Linq expression based on <paramref name="expression"/> (converted to a fully-qualified name) run against
|
/// Linq expression based on <paramref name="expression"/> (converted to a fully-qualified name) run against
|
||||||
|
|
@ -50,8 +48,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// value "checked" if the <see cref="bool"/> values is <c>true</c>; does not include the attribute otherwise.
|
/// value "checked" if the <see cref="bool"/> values is <c>true</c>; does not include the attribute otherwise.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent CheckBox([NotNull] this IHtmlHelper htmlHelper, string expression)
|
public static IHtmlContent CheckBox(this IHtmlHelper htmlHelper, string expression)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.CheckBox(expression, isChecked: null, htmlAttributes: null);
|
return htmlHelper.CheckBox(expression, isChecked: null, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -65,8 +68,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> elements.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> elements.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set checkbox
|
/// Combines <see cref="ViewFeatures.TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
||||||
/// element's "name" attribute. Sanitizes <paramref name="expression"/> to set checkbox element's "id"
|
/// checkbox element's "name" attribute. Sanitizes <paramref name="expression"/> to set checkbox element's "id"
|
||||||
/// attribute.
|
/// attribute.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// <para>Determines checkbox element's "checked" attribute based on the following precedence:</para>
|
/// <para>Determines checkbox element's "checked" attribute based on the following precedence:</para>
|
||||||
|
|
@ -77,8 +80,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </item>
|
/// </item>
|
||||||
/// <item><paramref name="isChecked"/> if non-<c>null</c>.</item>
|
/// <item><paramref name="isChecked"/> if non-<c>null</c>.</item>
|
||||||
/// <item>
|
/// <item>
|
||||||
/// <see cref="ViewDataDictionary"/> entry for <paramref name="expression"/> (converted to a fully-qualified
|
/// <see cref="ViewFeatures.ViewDataDictionary"/> entry for <paramref name="expression"/> (converted to a
|
||||||
/// name) if entry exists and can be converted to a <see cref="bool"/>.
|
/// fully-qualified name) if entry exists and can be converted to a <see cref="bool"/>.
|
||||||
/// </item>
|
/// </item>
|
||||||
/// <item>
|
/// <item>
|
||||||
/// Linq expression based on <paramref name="expression"/> (converted to a fully-qualified name) run against
|
/// Linq expression based on <paramref name="expression"/> (converted to a fully-qualified name) run against
|
||||||
|
|
@ -94,10 +97,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent CheckBox(
|
public static IHtmlContent CheckBox(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string expression,
|
string expression,
|
||||||
bool isChecked)
|
bool isChecked)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.CheckBox(expression, isChecked, htmlAttributes: null);
|
return htmlHelper.CheckBox(expression, isChecked, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -115,8 +123,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> elements.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> elements.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set checkbox
|
/// Combines <see cref="ViewFeatures.TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
||||||
/// element's "name" attribute. Sanitizes <paramref name="expression"/> to set checkbox element's "id"
|
/// checkbox element's "name" attribute. Sanitizes <paramref name="expression"/> to set checkbox element's "id"
|
||||||
/// attribute.
|
/// attribute.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// <para>Determines checkbox element's "checked" attribute based on the following precedence:</para>
|
/// <para>Determines checkbox element's "checked" attribute based on the following precedence:</para>
|
||||||
|
|
@ -126,8 +134,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// fully-qualified name) if entry exists and can be converted to a <see cref="bool"/>.
|
/// fully-qualified name) if entry exists and can be converted to a <see cref="bool"/>.
|
||||||
/// </item>
|
/// </item>
|
||||||
/// <item>
|
/// <item>
|
||||||
/// <see cref="ViewDataDictionary"/> entry for <paramref name="expression"/> (converted to a fully-qualified
|
/// <see cref="ViewFeatures.ViewDataDictionary"/> entry for <paramref name="expression"/> (converted to a
|
||||||
/// name) if entry exists and can be converted to a <see cref="bool"/>.
|
/// fully-qualified name) if entry exists and can be converted to a <see cref="bool"/>.
|
||||||
/// </item>
|
/// </item>
|
||||||
/// <item>
|
/// <item>
|
||||||
/// Linq expression based on <paramref name="expression"/> (converted to a fully-qualified name) run against
|
/// Linq expression based on <paramref name="expression"/> (converted to a fully-qualified name) run against
|
||||||
|
|
@ -144,10 +152,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent CheckBox(
|
public static IHtmlContent CheckBox(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string expression,
|
string expression,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.CheckBox(expression, isChecked: null, htmlAttributes: htmlAttributes);
|
return htmlHelper.CheckBox(expression, isChecked: null, htmlAttributes: htmlAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -160,7 +173,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> elements.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> elements.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and the string representation of the
|
/// Combines <see cref="ViewFeatures.TemplateInfo.HtmlFieldPrefix"/> and the string representation of the
|
||||||
/// <paramref name="expression"/> to set checkbox element's "name" attribute. Sanitizes the string
|
/// <paramref name="expression"/> to set checkbox element's "name" attribute. Sanitizes the string
|
||||||
/// representation of the <paramref name="expression"/> to set checkbox element's "id" attribute.
|
/// representation of the <paramref name="expression"/> to set checkbox element's "id" attribute.
|
||||||
/// </para>
|
/// </para>
|
||||||
|
|
@ -182,9 +195,19 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent CheckBoxFor<TModel>(
|
public static IHtmlContent CheckBoxFor<TModel>(
|
||||||
[NotNull] this IHtmlHelper<TModel> htmlHelper,
|
this IHtmlHelper<TModel> htmlHelper,
|
||||||
[NotNull] Expression<Func<TModel, bool>> expression)
|
Expression<Func<TModel, bool>> expression)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.CheckBoxFor(expression, htmlAttributes: null);
|
return htmlHelper.CheckBoxFor(expression, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -196,7 +219,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
/// Combines <see cref="ViewFeatures.TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
||||||
/// <input> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
/// <input> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
||||||
/// attribute.
|
/// attribute.
|
||||||
/// </para>
|
/// </para>
|
||||||
|
|
@ -207,8 +230,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// fully-qualified name) if entry exists and can be converted to a <see cref="string"/>.
|
/// fully-qualified name) if entry exists and can be converted to a <see cref="string"/>.
|
||||||
/// </item>
|
/// </item>
|
||||||
/// <item>
|
/// <item>
|
||||||
/// <see cref="ViewDataDictionary"/> entry for <paramref name="expression"/> (converted to a fully-qualified
|
/// <see cref="ViewFeatures.ViewDataDictionary"/> entry for <paramref name="expression"/> (converted to a
|
||||||
/// name) if entry exists and can be converted to a <see cref="string"/>.
|
/// fully-qualified name) if entry exists and can be converted to a <see cref="string"/>.
|
||||||
/// </item>
|
/// </item>
|
||||||
/// <item>
|
/// <item>
|
||||||
/// Linq expression based on <paramref name="expression"/> (converted to a fully-qualified name) run against
|
/// Linq expression based on <paramref name="expression"/> (converted to a fully-qualified name) run against
|
||||||
|
|
@ -219,8 +242,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <item>Otherwise, <c>string.Empty</c>.</item>
|
/// <item>Otherwise, <c>string.Empty</c>.</item>
|
||||||
/// </list>
|
/// </list>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent Hidden([NotNull] this IHtmlHelper htmlHelper, string expression)
|
public static IHtmlContent Hidden(this IHtmlHelper htmlHelper, string expression)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.Hidden(expression, value: null, htmlAttributes: null);
|
return htmlHelper.Hidden(expression, value: null, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -233,7 +261,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
/// Combines <see cref="ViewFeatures.TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
||||||
/// <input> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
/// <input> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
||||||
/// attribute.
|
/// attribute.
|
||||||
/// </para>
|
/// </para>
|
||||||
|
|
@ -245,8 +273,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </item>
|
/// </item>
|
||||||
/// <item><paramref name="value"/> if non-<c>null</c>.</item>
|
/// <item><paramref name="value"/> if non-<c>null</c>.</item>
|
||||||
/// <item>
|
/// <item>
|
||||||
/// <see cref="ViewDataDictionary"/> entry for <paramref name="expression"/> (converted to a fully-qualified
|
/// <see cref="ViewFeatures.ViewDataDictionary"/> entry for <paramref name="expression"/> (converted to a
|
||||||
/// name) if entry exists and can be converted to a <see cref="string"/>.
|
/// fully-qualified name) if entry exists and can be converted to a <see cref="string"/>.
|
||||||
/// </item>
|
/// </item>
|
||||||
/// <item>
|
/// <item>
|
||||||
/// Linq expression based on <paramref name="expression"/> (converted to a fully-qualified name) run against
|
/// Linq expression based on <paramref name="expression"/> (converted to a fully-qualified name) run against
|
||||||
|
|
@ -258,10 +286,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </list>
|
/// </list>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent Hidden(
|
public static IHtmlContent Hidden(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string expression,
|
string expression,
|
||||||
object value)
|
object value)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.Hidden(expression, value, htmlAttributes: null);
|
return htmlHelper.Hidden(expression, value, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -275,7 +308,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and the string representation of the
|
/// Combines <see cref="ViewFeatures.TemplateInfo.HtmlFieldPrefix"/> and the string representation of the
|
||||||
/// <paramref name="expression"/> to set <input> element's "name" attribute. Sanitizes the string
|
/// <paramref name="expression"/> to set <input> element's "name" attribute. Sanitizes the string
|
||||||
/// representation of the <paramref name="expression"/> to set element's "id" attribute.
|
/// representation of the <paramref name="expression"/> to set element's "id" attribute.
|
||||||
/// </para>
|
/// </para>
|
||||||
|
|
@ -293,9 +326,19 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </list>
|
/// </list>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent HiddenFor<TModel, TResult>(
|
public static IHtmlContent HiddenFor<TModel, TResult>(
|
||||||
[NotNull] this IHtmlHelper<TModel> htmlHelper,
|
this IHtmlHelper<TModel> htmlHelper,
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression)
|
Expression<Func<TModel, TResult>> expression)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.HiddenFor(expression, htmlAttributes: null);
|
return htmlHelper.HiddenFor(expression, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -306,12 +349,17 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <param name="expression">Expression name, relative to the current model.</param>
|
/// <param name="expression">Expression name, relative to the current model.</param>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
/// Combines <see cref="ViewFeatures.TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
||||||
/// <input> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
/// <input> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
||||||
/// attribute. Sets <input> element's "value" attribute to <c>string.Empty</c>.
|
/// attribute. Sets <input> element's "value" attribute to <c>string.Empty</c>.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent Password([NotNull] this IHtmlHelper htmlHelper, string expression)
|
public static IHtmlContent Password(this IHtmlHelper htmlHelper, string expression)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.Password(expression, value: null, htmlAttributes: null);
|
return htmlHelper.Password(expression, value: null, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -324,7 +372,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
/// Combines <see cref="ViewFeatures.TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
||||||
/// <input> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
/// <input> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
||||||
/// attribute.
|
/// attribute.
|
||||||
/// </para>
|
/// </para>
|
||||||
|
|
@ -335,10 +383,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </list>
|
/// </list>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent Password(
|
public static IHtmlContent Password(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string expression,
|
string expression,
|
||||||
object value)
|
object value)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.Password(expression, value, htmlAttributes: null);
|
return htmlHelper.Password(expression, value, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -352,7 +405,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and the string representation of the
|
/// Combines <see cref="ViewFeatures.TemplateInfo.HtmlFieldPrefix"/> and the string representation of the
|
||||||
/// <paramref name="expression"/> to set <input> element's "name" attribute. Sanitizes the string
|
/// <paramref name="expression"/> to set <input> element's "name" attribute. Sanitizes the string
|
||||||
/// representation of the <paramref name="expression"/> to set element's "id" attribute.
|
/// representation of the <paramref name="expression"/> to set element's "id" attribute.
|
||||||
/// </para>
|
/// </para>
|
||||||
|
|
@ -366,9 +419,19 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </list>
|
/// </list>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent PasswordFor<TModel, TResult>(
|
public static IHtmlContent PasswordFor<TModel, TResult>(
|
||||||
[NotNull] this IHtmlHelper<TModel> htmlHelper,
|
this IHtmlHelper<TModel> htmlHelper,
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression)
|
Expression<Func<TModel, TResult>> expression)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.PasswordFor(expression, htmlAttributes: null);
|
return htmlHelper.PasswordFor(expression, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -381,7 +444,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
/// Combines <see cref="ViewFeatures.TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
||||||
/// <input> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
/// <input> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
||||||
/// attribute. Sets <input> element's "value" attribute to <paramref name="value"/>.
|
/// attribute. Sets <input> element's "value" attribute to <paramref name="value"/>.
|
||||||
/// </para>
|
/// </para>
|
||||||
|
|
@ -392,8 +455,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// fully-qualified name) if entry exists and can be converted to a <see cref="string"/>.
|
/// fully-qualified name) if entry exists and can be converted to a <see cref="string"/>.
|
||||||
/// </item>
|
/// </item>
|
||||||
/// <item>
|
/// <item>
|
||||||
/// <see cref="ViewDataDictionary"/> entry for <paramref name="expression"/> (converted to a fully-qualified
|
/// <see cref="ViewFeatures.ViewDataDictionary"/> entry for <paramref name="expression"/> (converted to a
|
||||||
/// name) if entry exists and can be converted to a <see cref="string"/>.
|
/// fully-qualified name) if entry exists and can be converted to a <see cref="string"/>.
|
||||||
/// </item>
|
/// </item>
|
||||||
/// <item>
|
/// <item>
|
||||||
/// Linq expression based on <paramref name="expression"/> (converted to a fully-qualified name) run against
|
/// Linq expression based on <paramref name="expression"/> (converted to a fully-qualified name) run against
|
||||||
|
|
@ -411,10 +474,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent RadioButton(
|
public static IHtmlContent RadioButton(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string expression,
|
string expression,
|
||||||
object value)
|
object value)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.RadioButton(expression, value, isChecked: null, htmlAttributes: null);
|
return htmlHelper.RadioButton(expression, value, isChecked: null, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -435,7 +503,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
/// Combines <see cref="ViewFeatures.TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
||||||
/// <input> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
/// <input> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
||||||
/// attribute.
|
/// attribute.
|
||||||
/// </para>
|
/// </para>
|
||||||
|
|
@ -453,8 +521,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </item>
|
/// </item>
|
||||||
/// <item>Existing "checked" entry in <paramref name="htmlAttributes"/> if any.</item>
|
/// <item>Existing "checked" entry in <paramref name="htmlAttributes"/> if any.</item>
|
||||||
/// <item>
|
/// <item>
|
||||||
/// <see cref="ViewDataDictionary"/> entry for <paramref name="expression"/> (converted to a fully-qualified
|
/// <see cref="ViewFeatures.ViewDataDictionary"/> entry for <paramref name="expression"/> (converted to a
|
||||||
/// name) if entry exists and can be converted to a <see cref="string"/>.
|
/// fully-qualified name) if entry exists and can be converted to a <see cref="string"/>.
|
||||||
/// </item>
|
/// </item>
|
||||||
/// <item>
|
/// <item>
|
||||||
/// Linq expression based on <paramref name="expression"/> (converted to a fully-qualified name) run against
|
/// Linq expression based on <paramref name="expression"/> (converted to a fully-qualified name) run against
|
||||||
|
|
@ -472,11 +540,16 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent RadioButton(
|
public static IHtmlContent RadioButton(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string expression,
|
string expression,
|
||||||
object value,
|
object value,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.RadioButton(expression, value, isChecked: null, htmlAttributes: htmlAttributes);
|
return htmlHelper.RadioButton(expression, value, isChecked: null, htmlAttributes: htmlAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -496,7 +569,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
/// Combines <see cref="ViewFeatures.TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
||||||
/// <input> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
/// <input> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
||||||
/// attribute.
|
/// attribute.
|
||||||
/// </para>
|
/// </para>
|
||||||
|
|
@ -513,8 +586,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </item>
|
/// </item>
|
||||||
/// <item><paramref name="isChecked"/> if non-<c>null</c>.</item>
|
/// <item><paramref name="isChecked"/> if non-<c>null</c>.</item>
|
||||||
/// <item>
|
/// <item>
|
||||||
/// <see cref="ViewDataDictionary"/> entry for <paramref name="expression"/> (converted to a fully-qualified
|
/// <see cref="ViewFeatures.ViewDataDictionary"/> entry for <paramref name="expression"/> (converted to a
|
||||||
/// name) if entry exists and can be converted to a <see cref="string"/>.
|
/// fully-qualified name) if entry exists and can be converted to a <see cref="string"/>.
|
||||||
/// </item>
|
/// </item>
|
||||||
/// <item>
|
/// <item>
|
||||||
/// Linq expression based on <paramref name="expression"/> (converted to a fully-qualified name) run against
|
/// Linq expression based on <paramref name="expression"/> (converted to a fully-qualified name) run against
|
||||||
|
|
@ -532,11 +605,16 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent RadioButton(
|
public static IHtmlContent RadioButton(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string expression,
|
string expression,
|
||||||
object value,
|
object value,
|
||||||
bool isChecked)
|
bool isChecked)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.RadioButton(expression, value, isChecked, htmlAttributes: null);
|
return htmlHelper.RadioButton(expression, value, isChecked, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -551,7 +629,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and the string representation of the
|
/// Combines <see cref="ViewFeatures.TemplateInfo.HtmlFieldPrefix"/> and the string representation of the
|
||||||
/// <paramref name="expression"/> to set <select> element's "name" attribute. Sanitizes the string
|
/// <paramref name="expression"/> to set <select> element's "name" attribute. Sanitizes the string
|
||||||
/// representation of the <paramref name="expression"/> to set element's "id" attribute. Converts the
|
/// representation of the <paramref name="expression"/> to set element's "id" attribute. Converts the
|
||||||
/// <paramref name="value"/> to a <see cref="string"/> to set element's "value" attribute.
|
/// <paramref name="value"/> to a <see cref="string"/> to set element's "value" attribute.
|
||||||
|
|
@ -574,10 +652,25 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent RadioButtonFor<TModel, TResult>(
|
public static IHtmlContent RadioButtonFor<TModel, TResult>(
|
||||||
[NotNull] this IHtmlHelper<TModel> htmlHelper,
|
this IHtmlHelper<TModel> htmlHelper,
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
[NotNull] object value)
|
object value)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(value));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.RadioButtonFor(expression, value, htmlAttributes: null);
|
return htmlHelper.RadioButtonFor(expression, value, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -589,7 +682,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
/// Combines <see cref="ViewFeatures.TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
||||||
/// <input> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
/// <input> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
||||||
/// attribute.
|
/// attribute.
|
||||||
/// </para>
|
/// </para>
|
||||||
|
|
@ -600,8 +693,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// fully-qualified name) if entry exists and can be converted to a <see cref="string"/>.
|
/// fully-qualified name) if entry exists and can be converted to a <see cref="string"/>.
|
||||||
/// </item>
|
/// </item>
|
||||||
/// <item>
|
/// <item>
|
||||||
/// <see cref="ViewDataDictionary"/> entry for <paramref name="expression"/> (converted to a fully-qualified
|
/// <see cref="ViewFeatures.ViewDataDictionary"/> entry for <paramref name="expression"/> (converted to a
|
||||||
/// name) if entry exists and can be converted to a <see cref="string"/>.
|
/// fully-qualified name) if entry exists and can be converted to a <see cref="string"/>.
|
||||||
/// </item>
|
/// </item>
|
||||||
/// <item>
|
/// <item>
|
||||||
/// Linq expression based on <paramref name="expression"/> (converted to a fully-qualified name) run against
|
/// Linq expression based on <paramref name="expression"/> (converted to a fully-qualified name) run against
|
||||||
|
|
@ -612,8 +705,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <item>Otherwise, <c>string.Empty</c>.</item>
|
/// <item>Otherwise, <c>string.Empty</c>.</item>
|
||||||
/// </list>
|
/// </list>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent TextBox([NotNull] this IHtmlHelper htmlHelper, string expression)
|
public static IHtmlContent TextBox(this IHtmlHelper htmlHelper, string expression)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.TextBox(expression, value: null, format: null, htmlAttributes: null);
|
return htmlHelper.TextBox(expression, value: null, format: null, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -626,7 +724,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
/// Combines <see cref="ViewFeatures.TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
||||||
/// <input> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
/// <input> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
||||||
/// attribute.
|
/// attribute.
|
||||||
/// </para>
|
/// </para>
|
||||||
|
|
@ -640,8 +738,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <paramref name="value"/> if non-<c>null</c>.
|
/// <paramref name="value"/> if non-<c>null</c>.
|
||||||
/// </item>
|
/// </item>
|
||||||
/// <item>
|
/// <item>
|
||||||
/// <see cref="ViewDataDictionary"/> entry for <paramref name="expression"/> (converted to a fully-qualified
|
/// <see cref="ViewFeatures.ViewDataDictionary"/> entry for <paramref name="expression"/> (converted to a
|
||||||
/// name) if entry exists and can be converted to a <see cref="string"/>.
|
/// fully-qualified name) if entry exists and can be converted to a <see cref="string"/>.
|
||||||
/// </item>
|
/// </item>
|
||||||
/// <item>
|
/// <item>
|
||||||
/// Linq expression based on <paramref name="expression"/> (converted to a fully-qualified name) run against
|
/// Linq expression based on <paramref name="expression"/> (converted to a fully-qualified name) run against
|
||||||
|
|
@ -653,10 +751,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </list>
|
/// </list>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent TextBox(
|
public static IHtmlContent TextBox(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string expression,
|
string expression,
|
||||||
object value)
|
object value)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.TextBox(expression, value, format: null, htmlAttributes: null);
|
return htmlHelper.TextBox(expression, value, format: null, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -672,7 +775,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
/// Combines <see cref="ViewFeatures.TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
||||||
/// <input> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
/// <input> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
||||||
/// attribute.
|
/// attribute.
|
||||||
/// </para>
|
/// </para>
|
||||||
|
|
@ -688,8 +791,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <paramref name="format"/> is <c>null</c> or empty.
|
/// <paramref name="format"/> is <c>null</c> or empty.
|
||||||
/// </item>
|
/// </item>
|
||||||
/// <item>
|
/// <item>
|
||||||
/// <see cref="ViewDataDictionary"/> entry for <paramref name="expression"/> (converted to a fully-qualified
|
/// <see cref="ViewFeatures.ViewDataDictionary"/> entry for <paramref name="expression"/> (converted to a
|
||||||
/// name) if entry exists and can be converted to a <see cref="string"/>. Formats entry using
|
/// fully-qualified name) if entry exists and can be converted to a <see cref="string"/>. Formats entry using
|
||||||
/// <paramref name="format"/> or converts entry to a <see cref="string"/> directly if <paramref name="format"/>
|
/// <paramref name="format"/> or converts entry to a <see cref="string"/> directly if <paramref name="format"/>
|
||||||
/// is <c>null</c> or empty.
|
/// is <c>null</c> or empty.
|
||||||
/// </item>
|
/// </item>
|
||||||
|
|
@ -704,11 +807,16 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </list>
|
/// </list>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent TextBox(
|
public static IHtmlContent TextBox(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string expression,
|
string expression,
|
||||||
object value,
|
object value,
|
||||||
string format)
|
string format)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.TextBox(expression, value, format, htmlAttributes: null);
|
return htmlHelper.TextBox(expression, value, format, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -726,7 +834,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
/// Combines <see cref="ViewFeatures.TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
||||||
/// <input> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
/// <input> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
||||||
/// attribute.
|
/// attribute.
|
||||||
/// </para>
|
/// </para>
|
||||||
|
|
@ -740,8 +848,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <paramref name="value"/> if non-<c>null</c>.
|
/// <paramref name="value"/> if non-<c>null</c>.
|
||||||
/// </item>
|
/// </item>
|
||||||
/// <item>
|
/// <item>
|
||||||
/// <see cref="ViewDataDictionary"/> entry for <paramref name="expression"/> (converted to a fully-qualified
|
/// <see cref="ViewFeatures.ViewDataDictionary"/> entry for <paramref name="expression"/> (converted to a
|
||||||
/// name) if entry exists and can be converted to a <see cref="string"/>.
|
/// fully-qualified name) if entry exists and can be converted to a <see cref="string"/>.
|
||||||
/// </item>
|
/// </item>
|
||||||
/// <item>
|
/// <item>
|
||||||
/// Linq expression based on <paramref name="expression"/> (converted to a fully-qualified name) run against
|
/// Linq expression based on <paramref name="expression"/> (converted to a fully-qualified name) run against
|
||||||
|
|
@ -754,11 +862,16 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </list>
|
/// </list>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent TextBox(
|
public static IHtmlContent TextBox(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string expression,
|
string expression,
|
||||||
object value,
|
object value,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.TextBox(expression, value, format: null, htmlAttributes: htmlAttributes);
|
return htmlHelper.TextBox(expression, value, format: null, htmlAttributes: htmlAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -772,7 +885,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and the string representation of the
|
/// Combines <see cref="ViewFeatures.TemplateInfo.HtmlFieldPrefix"/> and the string representation of the
|
||||||
/// <paramref name="expression"/> to set <input> element's "name" attribute. Sanitizes the string
|
/// <paramref name="expression"/> to set <input> element's "name" attribute. Sanitizes the string
|
||||||
/// representation of the <paramref name="expression"/> to set element's "id" attribute.
|
/// representation of the <paramref name="expression"/> to set element's "id" attribute.
|
||||||
/// </para>
|
/// </para>
|
||||||
|
|
@ -789,9 +902,19 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </list>
|
/// </list>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent TextBoxFor<TModel, TResult>(
|
public static IHtmlContent TextBoxFor<TModel, TResult>(
|
||||||
[NotNull] this IHtmlHelper<TModel> htmlHelper,
|
this IHtmlHelper<TModel> htmlHelper,
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression)
|
Expression<Func<TModel, TResult>> expression)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.TextBoxFor(expression, format: null, htmlAttributes: null);
|
return htmlHelper.TextBoxFor(expression, format: null, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -808,7 +931,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and the string representation of the
|
/// Combines <see cref="ViewFeatures.TemplateInfo.HtmlFieldPrefix"/> and the string representation of the
|
||||||
/// <paramref name="expression"/> to set <input> element's "name" attribute. Sanitizes the string
|
/// <paramref name="expression"/> to set <input> element's "name" attribute. Sanitizes the string
|
||||||
/// representation of the <paramref name="expression"/> to set element's "id" attribute.
|
/// representation of the <paramref name="expression"/> to set element's "id" attribute.
|
||||||
/// </para>
|
/// </para>
|
||||||
|
|
@ -827,10 +950,20 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </list>
|
/// </list>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent TextBoxFor<TModel, TResult>(
|
public static IHtmlContent TextBoxFor<TModel, TResult>(
|
||||||
[NotNull] this IHtmlHelper<TModel> htmlHelper,
|
this IHtmlHelper<TModel> htmlHelper,
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
string format)
|
string format)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.TextBoxFor(expression, format, htmlAttributes: null);
|
return htmlHelper.TextBoxFor(expression, format, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -849,7 +982,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <input> element.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and the string representation of the
|
/// Combines <see cref="ViewFeatures.TemplateInfo.HtmlFieldPrefix"/> and the string representation of the
|
||||||
/// <paramref name="expression"/> to set <input> element's "name" attribute. Sanitizes the string
|
/// <paramref name="expression"/> to set <input> element's "name" attribute. Sanitizes the string
|
||||||
/// representation of the <paramref name="expression"/> to set element's "id" attribute.
|
/// representation of the <paramref name="expression"/> to set element's "id" attribute.
|
||||||
/// </para>
|
/// </para>
|
||||||
|
|
@ -867,10 +1000,20 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </list>
|
/// </list>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent TextBoxFor<TModel, TResult>(
|
public static IHtmlContent TextBoxFor<TModel, TResult>(
|
||||||
[NotNull] this IHtmlHelper<TModel> htmlHelper,
|
this IHtmlHelper<TModel> htmlHelper,
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.TextBoxFor(expression, format: null, htmlAttributes: htmlAttributes);
|
return htmlHelper.TextBoxFor(expression, format: null, htmlAttributes: htmlAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -882,7 +1025,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <textarea> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <textarea> element.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
/// Combines <see cref="ViewFeatures.TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
||||||
/// <textarea> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
/// <textarea> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
||||||
/// attribute.
|
/// attribute.
|
||||||
/// </para>
|
/// </para>
|
||||||
|
|
@ -893,8 +1036,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// fully-qualified name) if entry exists and can be converted to a <see cref="string"/>.
|
/// fully-qualified name) if entry exists and can be converted to a <see cref="string"/>.
|
||||||
/// </item>
|
/// </item>
|
||||||
/// <item>
|
/// <item>
|
||||||
/// <see cref="ViewDataDictionary"/> entry for <paramref name="expression"/> (converted to a fully-qualified
|
/// <see cref="ViewFeatures.ViewDataDictionary"/> entry for <paramref name="expression"/> (converted to a
|
||||||
/// name) if entry exists and can be converted to a <see cref="string"/>.
|
/// fully-qualified name) if entry exists and can be converted to a <see cref="string"/>.
|
||||||
/// </item>
|
/// </item>
|
||||||
/// <item>
|
/// <item>
|
||||||
/// Linq expression based on <paramref name="expression"/> (converted to a fully-qualified name) run against
|
/// Linq expression based on <paramref name="expression"/> (converted to a fully-qualified name) run against
|
||||||
|
|
@ -906,9 +1049,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </list>
|
/// </list>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent TextArea(
|
public static IHtmlContent TextArea(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string expression)
|
string expression)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.TextArea(expression, value: null, rows: 0, columns: 0, htmlAttributes: null);
|
return htmlHelper.TextArea(expression, value: null, rows: 0, columns: 0, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -925,7 +1073,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <textarea> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <textarea> element.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
/// Combines <see cref="ViewFeatures.TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
||||||
/// <textarea> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
/// <textarea> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
||||||
/// attribute.
|
/// attribute.
|
||||||
/// </para>
|
/// </para>
|
||||||
|
|
@ -936,8 +1084,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// fully-qualified name) if entry exists and can be converted to a <see cref="string"/>.
|
/// fully-qualified name) if entry exists and can be converted to a <see cref="string"/>.
|
||||||
/// </item>
|
/// </item>
|
||||||
/// <item>
|
/// <item>
|
||||||
/// <see cref="ViewDataDictionary"/> entry for <paramref name="expression"/> (converted to a fully-qualified
|
/// <see cref="ViewFeatures.ViewDataDictionary"/> entry for <paramref name="expression"/> (converted to a
|
||||||
/// name) if entry exists and can be converted to a <see cref="string"/>.
|
/// fully-qualified name) if entry exists and can be converted to a <see cref="string"/>.
|
||||||
/// </item>
|
/// </item>
|
||||||
/// <item>
|
/// <item>
|
||||||
/// Linq expression based on <paramref name="expression"/> (converted to a fully-qualified name) run against
|
/// Linq expression based on <paramref name="expression"/> (converted to a fully-qualified name) run against
|
||||||
|
|
@ -949,10 +1097,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </list>
|
/// </list>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent TextArea(
|
public static IHtmlContent TextArea(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string expression,
|
string expression,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.TextArea(expression, value: null, rows: 0, columns: 0, htmlAttributes: htmlAttributes);
|
return htmlHelper.TextArea(expression, value: null, rows: 0, columns: 0, htmlAttributes: htmlAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -965,7 +1118,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <textarea> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <textarea> element.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
/// Combines <see cref="ViewFeatures.TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
||||||
/// <textarea> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
/// <textarea> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
||||||
/// attribute.
|
/// attribute.
|
||||||
/// </para>
|
/// </para>
|
||||||
|
|
@ -977,8 +1130,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </item>
|
/// </item>
|
||||||
/// <item><paramref name="value"/> if non-<c>null</c>.</item>
|
/// <item><paramref name="value"/> if non-<c>null</c>.</item>
|
||||||
/// <item>
|
/// <item>
|
||||||
/// <see cref="ViewDataDictionary"/> entry for <paramref name="expression"/> (converted to a fully-qualified
|
/// <see cref="ViewFeatures.ViewDataDictionary"/> entry for <paramref name="expression"/> (converted to a
|
||||||
/// name) if entry exists and can be converted to a <see cref="string"/>.
|
/// fully-qualified name) if entry exists and can be converted to a <see cref="string"/>.
|
||||||
/// </item>
|
/// </item>
|
||||||
/// <item>
|
/// <item>
|
||||||
/// Linq expression based on <paramref name="expression"/> (converted to a fully-qualified name) run against
|
/// Linq expression based on <paramref name="expression"/> (converted to a fully-qualified name) run against
|
||||||
|
|
@ -990,10 +1143,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </list>
|
/// </list>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent TextArea(
|
public static IHtmlContent TextArea(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string expression,
|
string expression,
|
||||||
string value)
|
string value)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.TextArea(expression, value, rows: 0, columns: 0, htmlAttributes: null);
|
return htmlHelper.TextArea(expression, value, rows: 0, columns: 0, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1011,7 +1169,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <textarea> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <textarea> element.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
/// Combines <see cref="ViewFeatures.TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
||||||
/// <textarea> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
/// <textarea> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
||||||
/// attribute.
|
/// attribute.
|
||||||
/// </para>
|
/// </para>
|
||||||
|
|
@ -1023,8 +1181,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </item>
|
/// </item>
|
||||||
/// <item><paramref name="value"/> if non-<c>null</c>.</item>
|
/// <item><paramref name="value"/> if non-<c>null</c>.</item>
|
||||||
/// <item>
|
/// <item>
|
||||||
/// <see cref="ViewDataDictionary"/> entry for <paramref name="expression"/> (converted to a fully-qualified
|
/// <see cref="ViewFeatures.ViewDataDictionary"/> entry for <paramref name="expression"/> (converted to a
|
||||||
/// name) if entry exists and can be converted to a <see cref="string"/>.
|
/// fully-qualified name) if entry exists and can be converted to a <see cref="string"/>.
|
||||||
/// </item>
|
/// </item>
|
||||||
/// <item>
|
/// <item>
|
||||||
/// Linq expression based on <paramref name="expression"/> (converted to a fully-qualified name) run against
|
/// Linq expression based on <paramref name="expression"/> (converted to a fully-qualified name) run against
|
||||||
|
|
@ -1036,11 +1194,16 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </list>
|
/// </list>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent TextArea(
|
public static IHtmlContent TextArea(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string expression,
|
string expression,
|
||||||
string value,
|
string value,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.TextArea(expression, value, rows: 0, columns: 0, htmlAttributes: htmlAttributes);
|
return htmlHelper.TextArea(expression, value, rows: 0, columns: 0, htmlAttributes: htmlAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1054,7 +1217,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <textarea> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <textarea> element.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and the string representation of the
|
/// Combines <see cref="ViewFeatures.TemplateInfo.HtmlFieldPrefix"/> and the string representation of the
|
||||||
/// <paramref name="expression"/> to set <textarea> element's "name" attribute. Sanitizes the string
|
/// <paramref name="expression"/> to set <textarea> element's "name" attribute. Sanitizes the string
|
||||||
/// representation of the <paramref name="expression"/> to set element's "id" attribute.
|
/// representation of the <paramref name="expression"/> to set element's "id" attribute.
|
||||||
/// </para>
|
/// </para>
|
||||||
|
|
@ -1071,9 +1234,19 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </list>
|
/// </list>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent TextAreaFor<TModel, TResult>(
|
public static IHtmlContent TextAreaFor<TModel, TResult>(
|
||||||
[NotNull] this IHtmlHelper<TModel> htmlHelper,
|
this IHtmlHelper<TModel> htmlHelper,
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression)
|
Expression<Func<TModel, TResult>> expression)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.TextAreaFor(expression, rows: 0, columns: 0, htmlAttributes: null);
|
return htmlHelper.TextAreaFor(expression, rows: 0, columns: 0, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1092,7 +1265,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <textarea> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <textarea> element.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and the string representation of the
|
/// Combines <see cref="ViewFeatures.TemplateInfo.HtmlFieldPrefix"/> and the string representation of the
|
||||||
/// <paramref name="expression"/> to set <textarea> element's "name" attribute. Sanitizes the string
|
/// <paramref name="expression"/> to set <textarea> element's "name" attribute. Sanitizes the string
|
||||||
/// representation of the <paramref name="expression"/> to set element's "id" attribute.
|
/// representation of the <paramref name="expression"/> to set element's "id" attribute.
|
||||||
/// </para>
|
/// </para>
|
||||||
|
|
@ -1109,10 +1282,20 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </list>
|
/// </list>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent TextAreaFor<TModel, TResult>(
|
public static IHtmlContent TextAreaFor<TModel, TResult>(
|
||||||
[NotNull] this IHtmlHelper<TModel> htmlHelper,
|
this IHtmlHelper<TModel> htmlHelper,
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.TextAreaFor(expression, rows: 0, columns: 0, htmlAttributes: htmlAttributes);
|
return htmlHelper.TextAreaFor(expression, rows: 0, columns: 0, htmlAttributes: htmlAttributes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using Microsoft.AspNet.Html.Abstractions;
|
using Microsoft.AspNet.Html.Abstractions;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.Rendering
|
namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
{
|
{
|
||||||
|
|
@ -20,8 +18,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
|
/// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
|
||||||
/// <param name="expression">Expression name, relative to the current model.</param>
|
/// <param name="expression">Expression name, relative to the current model.</param>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <label> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <label> element.</returns>
|
||||||
public static IHtmlContent Label([NotNull] this IHtmlHelper htmlHelper, string expression)
|
public static IHtmlContent Label(this IHtmlHelper htmlHelper, string expression)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.Label(expression, labelText: null, htmlAttributes: null);
|
return htmlHelper.Label(expression, labelText: null, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -32,8 +35,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <param name="expression">Expression name, relative to the current model.</param>
|
/// <param name="expression">Expression name, relative to the current model.</param>
|
||||||
/// <param name="labelText">The inner text of the element.</param>
|
/// <param name="labelText">The inner text of the element.</param>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <label> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <label> element.</returns>
|
||||||
public static IHtmlContent Label([NotNull] this IHtmlHelper htmlHelper, string expression, string labelText)
|
public static IHtmlContent Label(this IHtmlHelper htmlHelper, string expression, string labelText)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.Label(expression, labelText, htmlAttributes: null);
|
return htmlHelper.Label(expression, labelText, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -46,9 +54,19 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
|
/// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <label> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <label> element.</returns>
|
||||||
public static IHtmlContent LabelFor<TModel, TResult>(
|
public static IHtmlContent LabelFor<TModel, TResult>(
|
||||||
[NotNull] this IHtmlHelper<TModel> htmlHelper,
|
this IHtmlHelper<TModel> htmlHelper,
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression)
|
Expression<Func<TModel, TResult>> expression)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.LabelFor<TResult>(expression, labelText: null, htmlAttributes: null);
|
return htmlHelper.LabelFor<TResult>(expression, labelText: null, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -62,10 +80,20 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
|
/// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <label> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <label> element.</returns>
|
||||||
public static IHtmlContent LabelFor<TModel, TResult>(
|
public static IHtmlContent LabelFor<TModel, TResult>(
|
||||||
[NotNull] this IHtmlHelper<TModel> htmlHelper,
|
this IHtmlHelper<TModel> htmlHelper,
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
string labelText)
|
string labelText)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.LabelFor<TResult>(expression, labelText, htmlAttributes: null);
|
return htmlHelper.LabelFor<TResult>(expression, labelText, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -83,10 +111,20 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
|
/// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <label> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <label> element.</returns>
|
||||||
public static IHtmlContent LabelFor<TModel, TResult>(
|
public static IHtmlContent LabelFor<TModel, TResult>(
|
||||||
[NotNull] this IHtmlHelper<TModel> htmlHelper,
|
this IHtmlHelper<TModel> htmlHelper,
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.LabelFor<TResult>(expression, labelText: null, htmlAttributes: htmlAttributes);
|
return htmlHelper.LabelFor<TResult>(expression, labelText: null, htmlAttributes: htmlAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -95,8 +133,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
|
/// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <label> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <label> element.</returns>
|
||||||
public static IHtmlContent LabelForModel([NotNull] this IHtmlHelper htmlHelper)
|
public static IHtmlContent LabelForModel(this IHtmlHelper htmlHelper)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.Label(expression: null, labelText: null, htmlAttributes: null);
|
return htmlHelper.Label(expression: null, labelText: null, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -106,8 +149,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
|
/// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
|
||||||
/// <param name="labelText">The inner text of the element.</param>
|
/// <param name="labelText">The inner text of the element.</param>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <label> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <label> element.</returns>
|
||||||
public static IHtmlContent LabelForModel([NotNull] this IHtmlHelper htmlHelper, string labelText)
|
public static IHtmlContent LabelForModel(this IHtmlHelper htmlHelper, string labelText)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.Label(expression: null, labelText: labelText, htmlAttributes: null);
|
return htmlHelper.Label(expression: null, labelText: labelText, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -121,8 +169,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// attributes.
|
/// attributes.
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <label> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <label> element.</returns>
|
||||||
public static IHtmlContent LabelForModel([NotNull] this IHtmlHelper htmlHelper, object htmlAttributes)
|
public static IHtmlContent LabelForModel(this IHtmlHelper htmlHelper, object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.Label(expression: null, labelText: null, htmlAttributes: htmlAttributes);
|
return htmlHelper.Label(expression: null, labelText: null, htmlAttributes: htmlAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -138,10 +191,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <label> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <label> element.</returns>
|
||||||
public static IHtmlContent LabelForModel(
|
public static IHtmlContent LabelForModel(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string labelText,
|
string labelText,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.Label(expression: null, labelText: labelText, htmlAttributes: htmlAttributes);
|
return htmlHelper.Label(expression: null, labelText: labelText, htmlAttributes: htmlAttributes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
using Microsoft.AspNet.Html.Abstractions;
|
using Microsoft.AspNet.Html.Abstractions;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.Rendering
|
namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
{
|
{
|
||||||
|
|
@ -20,10 +19,20 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <param name="actionName">The name of the action.</param>
|
/// <param name="actionName">The name of the action.</param>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the anchor element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the anchor element.</returns>
|
||||||
public static IHtmlContent ActionLink(
|
public static IHtmlContent ActionLink(
|
||||||
[NotNull] this IHtmlHelper helper,
|
this IHtmlHelper helper,
|
||||||
[NotNull] string linkText,
|
string linkText,
|
||||||
string actionName)
|
string actionName)
|
||||||
{
|
{
|
||||||
|
if (helper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(helper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (linkText == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(linkText));
|
||||||
|
}
|
||||||
|
|
||||||
return helper.ActionLink(
|
return helper.ActionLink(
|
||||||
linkText,
|
linkText,
|
||||||
actionName,
|
actionName,
|
||||||
|
|
@ -50,11 +59,21 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the anchor element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the anchor element.</returns>
|
||||||
public static IHtmlContent ActionLink(
|
public static IHtmlContent ActionLink(
|
||||||
[NotNull] this IHtmlHelper helper,
|
this IHtmlHelper helper,
|
||||||
[NotNull] string linkText,
|
string linkText,
|
||||||
string actionName,
|
string actionName,
|
||||||
object routeValues)
|
object routeValues)
|
||||||
{
|
{
|
||||||
|
if (helper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(helper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (linkText == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(linkText));
|
||||||
|
}
|
||||||
|
|
||||||
return helper.ActionLink(
|
return helper.ActionLink(
|
||||||
linkText,
|
linkText,
|
||||||
actionName,
|
actionName,
|
||||||
|
|
@ -86,12 +105,22 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the anchor element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the anchor element.</returns>
|
||||||
public static IHtmlContent ActionLink(
|
public static IHtmlContent ActionLink(
|
||||||
[NotNull] this IHtmlHelper helper,
|
this IHtmlHelper helper,
|
||||||
[NotNull] string linkText,
|
string linkText,
|
||||||
string actionName,
|
string actionName,
|
||||||
object routeValues,
|
object routeValues,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (helper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(helper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (linkText == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(linkText));
|
||||||
|
}
|
||||||
|
|
||||||
return helper.ActionLink(
|
return helper.ActionLink(
|
||||||
linkText,
|
linkText,
|
||||||
actionName,
|
actionName,
|
||||||
|
|
@ -112,11 +141,21 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <param name="controllerName">The name of the controller.</param>
|
/// <param name="controllerName">The name of the controller.</param>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the anchor element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the anchor element.</returns>
|
||||||
public static IHtmlContent ActionLink(
|
public static IHtmlContent ActionLink(
|
||||||
[NotNull] this IHtmlHelper helper,
|
this IHtmlHelper helper,
|
||||||
[NotNull] string linkText,
|
string linkText,
|
||||||
string actionName,
|
string actionName,
|
||||||
string controllerName)
|
string controllerName)
|
||||||
{
|
{
|
||||||
|
if (helper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(helper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (linkText == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(linkText));
|
||||||
|
}
|
||||||
|
|
||||||
return helper.ActionLink(
|
return helper.ActionLink(
|
||||||
linkText,
|
linkText,
|
||||||
actionName,
|
actionName,
|
||||||
|
|
@ -144,12 +183,22 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the anchor element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the anchor element.</returns>
|
||||||
public static IHtmlContent ActionLink(
|
public static IHtmlContent ActionLink(
|
||||||
[NotNull] this IHtmlHelper helper,
|
this IHtmlHelper helper,
|
||||||
[NotNull] string linkText,
|
string linkText,
|
||||||
string actionName,
|
string actionName,
|
||||||
string controllerName,
|
string controllerName,
|
||||||
object routeValues)
|
object routeValues)
|
||||||
{
|
{
|
||||||
|
if (helper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(helper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (linkText == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(linkText));
|
||||||
|
}
|
||||||
|
|
||||||
return helper.ActionLink(
|
return helper.ActionLink(
|
||||||
linkText,
|
linkText,
|
||||||
actionName,
|
actionName,
|
||||||
|
|
@ -182,13 +231,23 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the anchor element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the anchor element.</returns>
|
||||||
public static IHtmlContent ActionLink(
|
public static IHtmlContent ActionLink(
|
||||||
[NotNull] this IHtmlHelper helper,
|
this IHtmlHelper helper,
|
||||||
[NotNull] string linkText,
|
string linkText,
|
||||||
string actionName,
|
string actionName,
|
||||||
string controllerName,
|
string controllerName,
|
||||||
object routeValues,
|
object routeValues,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (helper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(helper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (linkText == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(linkText));
|
||||||
|
}
|
||||||
|
|
||||||
return helper.ActionLink(
|
return helper.ActionLink(
|
||||||
linkText,
|
linkText,
|
||||||
actionName,
|
actionName,
|
||||||
|
|
@ -214,10 +273,20 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the anchor element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the anchor element.</returns>
|
||||||
public static IHtmlContent RouteLink(
|
public static IHtmlContent RouteLink(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
[NotNull] string linkText,
|
string linkText,
|
||||||
object routeValues)
|
object routeValues)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (linkText == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(linkText));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.RouteLink(
|
return htmlHelper.RouteLink(
|
||||||
linkText,
|
linkText,
|
||||||
routeName: null,
|
routeName: null,
|
||||||
|
|
@ -236,10 +305,20 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <param name="routeName">The name of the route.</param>
|
/// <param name="routeName">The name of the route.</param>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the anchor element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the anchor element.</returns>
|
||||||
public static IHtmlContent RouteLink(
|
public static IHtmlContent RouteLink(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
[NotNull] string linkText,
|
string linkText,
|
||||||
string routeName)
|
string routeName)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (linkText == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(linkText));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.RouteLink(
|
return htmlHelper.RouteLink(
|
||||||
linkText,
|
linkText,
|
||||||
routeName,
|
routeName,
|
||||||
|
|
@ -265,11 +344,21 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the anchor element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the anchor element.</returns>
|
||||||
public static IHtmlContent RouteLink(
|
public static IHtmlContent RouteLink(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
[NotNull] string linkText,
|
string linkText,
|
||||||
string routeName,
|
string routeName,
|
||||||
object routeValues)
|
object routeValues)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (linkText == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(linkText));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.RouteLink(
|
return htmlHelper.RouteLink(
|
||||||
linkText,
|
linkText,
|
||||||
routeName,
|
routeName,
|
||||||
|
|
@ -299,11 +388,21 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the anchor element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the anchor element.</returns>
|
||||||
public static IHtmlContent RouteLink(
|
public static IHtmlContent RouteLink(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
[NotNull] string linkText,
|
string linkText,
|
||||||
object routeValues,
|
object routeValues,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (linkText == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(linkText));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.RouteLink(
|
return htmlHelper.RouteLink(
|
||||||
linkText,
|
linkText,
|
||||||
routeName: null,
|
routeName: null,
|
||||||
|
|
@ -334,12 +433,22 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the anchor element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the anchor element.</returns>
|
||||||
public static IHtmlContent RouteLink(
|
public static IHtmlContent RouteLink(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
[NotNull] string linkText,
|
string linkText,
|
||||||
string routeName,
|
string routeName,
|
||||||
object routeValues,
|
object routeValues,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (linkText == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(linkText));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.RouteLink(
|
return htmlHelper.RouteLink(
|
||||||
linkText,
|
linkText,
|
||||||
routeName,
|
routeName,
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
using System;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.Rendering
|
namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
{
|
{
|
||||||
|
|
@ -16,8 +15,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
|
/// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
|
||||||
/// <returns>A <see cref="string"/> containing the element name.</returns>
|
/// <returns>A <see cref="string"/> containing the element name.</returns>
|
||||||
public static string NameForModel([NotNull] this IHtmlHelper htmlHelper)
|
public static string NameForModel(this IHtmlHelper htmlHelper)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.Name(expression: null);
|
return htmlHelper.Name(expression: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -26,8 +30,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
|
/// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
|
||||||
/// <returns>A <see cref="string"/> containing the element Id.</returns>
|
/// <returns>A <see cref="string"/> containing the element Id.</returns>
|
||||||
public static string IdForModel([NotNull] this IHtmlHelper htmlHelper)
|
public static string IdForModel(this IHtmlHelper htmlHelper)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.Id(expression: null);
|
return htmlHelper.Id(expression: null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Html.Abstractions;
|
using Microsoft.AspNet.Html.Abstractions;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
using Microsoft.AspNet.Mvc.ViewFeatures;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.Rendering
|
namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
{
|
{
|
||||||
|
|
@ -25,9 +25,19 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// the created HTML.
|
/// the created HTML.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static Task<IHtmlContent> PartialAsync(
|
public static Task<IHtmlContent> PartialAsync(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
[NotNull] string partialViewName)
|
string partialViewName)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (partialViewName == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(partialViewName));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.PartialAsync(partialViewName, htmlHelper.ViewData.Model, viewData: null);
|
return htmlHelper.PartialAsync(partialViewName, htmlHelper.ViewData.Model, viewData: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -44,10 +54,20 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// the created HTML.
|
/// the created HTML.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static Task<IHtmlContent> PartialAsync(
|
public static Task<IHtmlContent> PartialAsync(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
[NotNull] string partialViewName,
|
string partialViewName,
|
||||||
ViewDataDictionary viewData)
|
ViewDataDictionary viewData)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (partialViewName == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(partialViewName));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.PartialAsync(partialViewName, htmlHelper.ViewData.Model, viewData: viewData);
|
return htmlHelper.PartialAsync(partialViewName, htmlHelper.ViewData.Model, viewData: viewData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -64,10 +84,20 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// the created HTML.
|
/// the created HTML.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static Task<IHtmlContent> PartialAsync(
|
public static Task<IHtmlContent> PartialAsync(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
[NotNull] string partialViewName,
|
string partialViewName,
|
||||||
object model)
|
object model)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (partialViewName == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(partialViewName));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.PartialAsync(partialViewName, model, viewData: null);
|
return htmlHelper.PartialAsync(partialViewName, model, viewData: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -86,9 +116,19 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <see cref="IHtmlHelper.PartialAsync(string, object, ViewDataDictionary)"/>
|
/// <see cref="IHtmlHelper.PartialAsync(string, object, ViewDataDictionary)"/>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent Partial(
|
public static IHtmlContent Partial(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
[NotNull] string partialViewName)
|
string partialViewName)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (partialViewName == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(partialViewName));
|
||||||
|
}
|
||||||
|
|
||||||
return Partial(htmlHelper, partialViewName, htmlHelper.ViewData.Model, viewData: null);
|
return Partial(htmlHelper, partialViewName, htmlHelper.ViewData.Model, viewData: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -108,10 +148,20 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <see cref="IHtmlHelper.PartialAsync(string, object, ViewDataDictionary)"/>
|
/// <see cref="IHtmlHelper.PartialAsync(string, object, ViewDataDictionary)"/>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent Partial(
|
public static IHtmlContent Partial(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
[NotNull] string partialViewName,
|
string partialViewName,
|
||||||
ViewDataDictionary viewData)
|
ViewDataDictionary viewData)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (partialViewName == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(partialViewName));
|
||||||
|
}
|
||||||
|
|
||||||
return Partial(htmlHelper, partialViewName, htmlHelper.ViewData.Model, viewData);
|
return Partial(htmlHelper, partialViewName, htmlHelper.ViewData.Model, viewData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -131,10 +181,20 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <see cref="IHtmlHelper.PartialAsync(string, object, ViewDataDictionary)"/>
|
/// <see cref="IHtmlHelper.PartialAsync(string, object, ViewDataDictionary)"/>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent Partial(
|
public static IHtmlContent Partial(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
[NotNull] string partialViewName,
|
string partialViewName,
|
||||||
object model)
|
object model)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (partialViewName == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(partialViewName));
|
||||||
|
}
|
||||||
|
|
||||||
return Partial(htmlHelper, partialViewName, model, viewData: null);
|
return Partial(htmlHelper, partialViewName, model, viewData: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -155,11 +215,21 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <see cref="IHtmlHelper.PartialAsync(string, object, ViewDataDictionary)"/>
|
/// <see cref="IHtmlHelper.PartialAsync(string, object, ViewDataDictionary)"/>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent Partial(
|
public static IHtmlContent Partial(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
[NotNull] string partialViewName,
|
string partialViewName,
|
||||||
object model,
|
object model,
|
||||||
ViewDataDictionary viewData)
|
ViewDataDictionary viewData)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (partialViewName == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(partialViewName));
|
||||||
|
}
|
||||||
|
|
||||||
var result = htmlHelper.PartialAsync(partialViewName, model, viewData);
|
var result = htmlHelper.PartialAsync(partialViewName, model, viewData);
|
||||||
return result.GetAwaiter().GetResult();
|
return result.GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
@ -176,9 +246,19 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static Task RenderPartialAsync(
|
public static Task RenderPartialAsync(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
[NotNull] string partialViewName)
|
string partialViewName)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (partialViewName == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(partialViewName));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.RenderPartialAsync(partialViewName, htmlHelper.ViewData.Model,
|
return htmlHelper.RenderPartialAsync(partialViewName, htmlHelper.ViewData.Model,
|
||||||
viewData: htmlHelper.ViewData);
|
viewData: htmlHelper.ViewData);
|
||||||
}
|
}
|
||||||
|
|
@ -196,10 +276,20 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static Task RenderPartialAsync(
|
public static Task RenderPartialAsync(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
[NotNull] string partialViewName,
|
string partialViewName,
|
||||||
ViewDataDictionary viewData)
|
ViewDataDictionary viewData)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (partialViewName == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(partialViewName));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.RenderPartialAsync(partialViewName, htmlHelper.ViewData.Model, viewData: viewData);
|
return htmlHelper.RenderPartialAsync(partialViewName, htmlHelper.ViewData.Model, viewData: viewData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -216,10 +306,20 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static Task RenderPartialAsync(
|
public static Task RenderPartialAsync(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
[NotNull] string partialViewName,
|
string partialViewName,
|
||||||
object model)
|
object model)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (partialViewName == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(partialViewName));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.RenderPartialAsync(partialViewName, model, htmlHelper.ViewData);
|
return htmlHelper.RenderPartialAsync(partialViewName, model, htmlHelper.ViewData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,6 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using Microsoft.AspNet.Html.Abstractions;
|
using Microsoft.AspNet.Html.Abstractions;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.Rendering
|
namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
{
|
{
|
||||||
|
|
@ -22,12 +20,17 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <param name="expression">Expression name, relative to the current model.</param>
|
/// <param name="expression">Expression name, relative to the current model.</param>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <select> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <select> element.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
/// Combines <see cref="ViewFeatures.TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
||||||
/// <select> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
/// <select> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
||||||
/// attribute.
|
/// attribute.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent DropDownList([NotNull] this IHtmlHelper htmlHelper, string expression)
|
public static IHtmlContent DropDownList(this IHtmlHelper htmlHelper, string expression)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.DropDownList(expression, selectList: null, optionLabel: null, htmlAttributes: null);
|
return htmlHelper.DropDownList(expression, selectList: null, optionLabel: null, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -42,15 +45,20 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <select> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <select> element.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
/// Combines <see cref="ViewFeatures.TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
||||||
/// <select> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
/// <select> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
||||||
/// attribute.
|
/// attribute.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent DropDownList(
|
public static IHtmlContent DropDownList(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string expression,
|
string expression,
|
||||||
string optionLabel)
|
string optionLabel)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.DropDownList(
|
return htmlHelper.DropDownList(
|
||||||
expression,
|
expression,
|
||||||
selectList: null,
|
selectList: null,
|
||||||
|
|
@ -70,15 +78,20 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <select> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <select> element.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
/// Combines <see cref="ViewFeatures.TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
||||||
/// <select> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
/// <select> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
||||||
/// attribute.
|
/// attribute.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent DropDownList(
|
public static IHtmlContent DropDownList(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string expression,
|
string expression,
|
||||||
IEnumerable<SelectListItem> selectList)
|
IEnumerable<SelectListItem> selectList)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.DropDownList(expression, selectList, optionLabel: null, htmlAttributes: null);
|
return htmlHelper.DropDownList(expression, selectList, optionLabel: null, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -98,16 +111,21 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <select> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <select> element.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
/// Combines <see cref="ViewFeatures.TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
||||||
/// <select> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
/// <select> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
||||||
/// attribute.
|
/// attribute.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent DropDownList(
|
public static IHtmlContent DropDownList(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string expression,
|
string expression,
|
||||||
IEnumerable<SelectListItem> selectList,
|
IEnumerable<SelectListItem> selectList,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.DropDownList(expression, selectList, optionLabel: null, htmlAttributes: htmlAttributes);
|
return htmlHelper.DropDownList(expression, selectList, optionLabel: null, htmlAttributes: htmlAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -126,16 +144,21 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <select> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <select> element.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
/// Combines <see cref="ViewFeatures.TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
||||||
/// <select> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
/// <select> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
||||||
/// attribute.
|
/// attribute.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent DropDownList(
|
public static IHtmlContent DropDownList(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string expression,
|
string expression,
|
||||||
IEnumerable<SelectListItem> selectList,
|
IEnumerable<SelectListItem> selectList,
|
||||||
string optionLabel)
|
string optionLabel)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.DropDownList(expression, selectList, optionLabel, htmlAttributes: null);
|
return htmlHelper.DropDownList(expression, selectList, optionLabel, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -153,15 +176,25 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
|
/// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <select> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <select> element.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and the string representation of the
|
/// Combines <see cref="ViewFeatures.TemplateInfo.HtmlFieldPrefix"/> and the string representation of the
|
||||||
/// <paramref name="expression"/> to set <select> element's "name" attribute. Sanitizes the string
|
/// <paramref name="expression"/> to set <select> element's "name" attribute. Sanitizes the string
|
||||||
/// representation of the <paramref name="expression"/> to set element's "id" attribute.
|
/// representation of the <paramref name="expression"/> to set element's "id" attribute.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent DropDownListFor<TModel, TResult>(
|
public static IHtmlContent DropDownListFor<TModel, TResult>(
|
||||||
[NotNull] this IHtmlHelper<TModel> htmlHelper,
|
this IHtmlHelper<TModel> htmlHelper,
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
IEnumerable<SelectListItem> selectList)
|
IEnumerable<SelectListItem> selectList)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.DropDownListFor(expression, selectList, optionLabel: null, htmlAttributes: null);
|
return htmlHelper.DropDownListFor(expression, selectList, optionLabel: null, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -183,16 +216,26 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
|
/// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <select> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <select> element.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and the string representation of the
|
/// Combines <see cref="ViewFeatures.TemplateInfo.HtmlFieldPrefix"/> and the string representation of the
|
||||||
/// <paramref name="expression"/> to set <select> element's "name" attribute. Sanitizes the string
|
/// <paramref name="expression"/> to set <select> element's "name" attribute. Sanitizes the string
|
||||||
/// representation of the <paramref name="expression"/> to set element's "id" attribute.
|
/// representation of the <paramref name="expression"/> to set element's "id" attribute.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent DropDownListFor<TModel, TResult>(
|
public static IHtmlContent DropDownListFor<TModel, TResult>(
|
||||||
[NotNull] this IHtmlHelper<TModel> htmlHelper,
|
this IHtmlHelper<TModel> htmlHelper,
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
IEnumerable<SelectListItem> selectList,
|
IEnumerable<SelectListItem> selectList,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.DropDownListFor(
|
return htmlHelper.DropDownListFor(
|
||||||
expression,
|
expression,
|
||||||
selectList,
|
selectList,
|
||||||
|
|
@ -217,16 +260,26 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
|
/// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <select> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <select> element.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and the string representation of the
|
/// Combines <see cref="ViewFeatures.TemplateInfo.HtmlFieldPrefix"/> and the string representation of the
|
||||||
/// <paramref name="expression"/> to set <select> element's "name" attribute. Sanitizes the string
|
/// <paramref name="expression"/> to set <select> element's "name" attribute. Sanitizes the string
|
||||||
/// representation of the <paramref name="expression"/> to set element's "id" attribute.
|
/// representation of the <paramref name="expression"/> to set element's "id" attribute.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent DropDownListFor<TModel, TResult>(
|
public static IHtmlContent DropDownListFor<TModel, TResult>(
|
||||||
[NotNull] this IHtmlHelper<TModel> htmlHelper,
|
this IHtmlHelper<TModel> htmlHelper,
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
IEnumerable<SelectListItem> selectList,
|
IEnumerable<SelectListItem> selectList,
|
||||||
string optionLabel)
|
string optionLabel)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.DropDownListFor(expression, selectList, optionLabel, htmlAttributes: null);
|
return htmlHelper.DropDownListFor(expression, selectList, optionLabel, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -237,12 +290,17 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <param name="expression">Expression name, relative to the current model.</param>
|
/// <param name="expression">Expression name, relative to the current model.</param>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <select> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <select> element.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
/// Combines <see cref="ViewFeatures.TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
||||||
/// <select> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
/// <select> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
||||||
/// attribute.
|
/// attribute.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent ListBox([NotNull] this IHtmlHelper htmlHelper, string expression)
|
public static IHtmlContent ListBox(this IHtmlHelper htmlHelper, string expression)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.ListBox(expression, selectList: null, htmlAttributes: null);
|
return htmlHelper.ListBox(expression, selectList: null, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -258,15 +316,20 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <select> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <select> element.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
/// Combines <see cref="ViewFeatures.TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
|
||||||
/// <select> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
/// <select> element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
|
||||||
/// attribute.
|
/// attribute.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent ListBox(
|
public static IHtmlContent ListBox(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string expression,
|
string expression,
|
||||||
IEnumerable<SelectListItem> selectList)
|
IEnumerable<SelectListItem> selectList)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.ListBox(expression, selectList, htmlAttributes: null);
|
return htmlHelper.ListBox(expression, selectList, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -284,15 +347,25 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
|
/// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <select> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <select> element.</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and the string representation of the
|
/// Combines <see cref="ViewFeatures.TemplateInfo.HtmlFieldPrefix"/> and the string representation of the
|
||||||
/// <paramref name="expression"/> to set <select> element's "name" attribute. Sanitizes the string
|
/// <paramref name="expression"/> to set <select> element's "name" attribute. Sanitizes the string
|
||||||
/// representation of the <paramref name="expression"/> to set element's "id" attribute.
|
/// representation of the <paramref name="expression"/> to set element's "id" attribute.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent ListBoxFor<TModel, TResult>(
|
public static IHtmlContent ListBoxFor<TModel, TResult>(
|
||||||
[NotNull] this IHtmlHelper<TModel> htmlHelper,
|
this IHtmlHelper<TModel> htmlHelper,
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
IEnumerable<SelectListItem> selectList)
|
IEnumerable<SelectListItem> selectList)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.ListBoxFor(expression, selectList, htmlAttributes: null);
|
return htmlHelper.ListBoxFor(expression, selectList, htmlAttributes: null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using Microsoft.AspNet.Html.Abstractions;
|
using Microsoft.AspNet.Html.Abstractions;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.Rendering
|
namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
{
|
{
|
||||||
|
|
@ -29,9 +27,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// will always be visible but client-side validation may update the associated CSS class.
|
/// will always be visible but client-side validation may update the associated CSS class.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent ValidationMessage(
|
public static IHtmlContent ValidationMessage(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string expression)
|
string expression)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.ValidationMessage(expression, message: null, htmlAttributes: null, tag: null);
|
return htmlHelper.ValidationMessage(expression, message: null, htmlAttributes: null, tag: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -51,10 +54,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <c>null</c> if the <paramref name="expression"/> is valid and client-side validation is disabled.
|
/// <c>null</c> if the <paramref name="expression"/> is valid and client-side validation is disabled.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static IHtmlContent ValidationMessage(
|
public static IHtmlContent ValidationMessage(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string expression,
|
string expression,
|
||||||
string message)
|
string message)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.ValidationMessage(expression, message, htmlAttributes: null, tag: null);
|
return htmlHelper.ValidationMessage(expression, message, htmlAttributes: null, tag: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -79,10 +87,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// will always be visible but client-side validation may update the associated CSS class.
|
/// will always be visible but client-side validation may update the associated CSS class.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent ValidationMessage(
|
public static IHtmlContent ValidationMessage(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string expression,
|
string expression,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.ValidationMessage(expression, message: null, htmlAttributes: htmlAttributes, tag: null);
|
return htmlHelper.ValidationMessage(expression, message: null, htmlAttributes: htmlAttributes, tag: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -106,11 +119,16 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <paramref name="expression"/> is valid and client-side validation is disabled.
|
/// <paramref name="expression"/> is valid and client-side validation is disabled.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static IHtmlContent ValidationMessage(
|
public static IHtmlContent ValidationMessage(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string expression,
|
string expression,
|
||||||
string message,
|
string message,
|
||||||
string tag)
|
string tag)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.ValidationMessage(expression, message, htmlAttributes: null, tag: tag);
|
return htmlHelper.ValidationMessage(expression, message, htmlAttributes: null, tag: tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -136,11 +154,16 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <c>null</c> if the <paramref name="expression"/> is valid and client-side validation is disabled.
|
/// <c>null</c> if the <paramref name="expression"/> is valid and client-side validation is disabled.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static IHtmlContent ValidationMessage(
|
public static IHtmlContent ValidationMessage(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string expression,
|
string expression,
|
||||||
string message,
|
string message,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.ValidationMessage(expression, message, htmlAttributes, tag: null);
|
return htmlHelper.ValidationMessage(expression, message, htmlAttributes, tag: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -161,9 +184,19 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// will always be visible but client-side validation may update the associated CSS class.
|
/// will always be visible but client-side validation may update the associated CSS class.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static IHtmlContent ValidationMessageFor<TModel, TResult>(
|
public static IHtmlContent ValidationMessageFor<TModel, TResult>(
|
||||||
[NotNull] this IHtmlHelper<TModel> htmlHelper,
|
this IHtmlHelper<TModel> htmlHelper,
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression)
|
Expression<Func<TModel, TResult>> expression)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.ValidationMessageFor(expression, message: null, htmlAttributes: null, tag: null);
|
return htmlHelper.ValidationMessageFor(expression, message: null, htmlAttributes: null, tag: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -185,10 +218,20 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <c>null</c> if the <paramref name="expression"/> is valid and client-side validation is disabled.
|
/// <c>null</c> if the <paramref name="expression"/> is valid and client-side validation is disabled.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static IHtmlContent ValidationMessageFor<TModel, TResult>(
|
public static IHtmlContent ValidationMessageFor<TModel, TResult>(
|
||||||
[NotNull] this IHtmlHelper<TModel> htmlHelper,
|
this IHtmlHelper<TModel> htmlHelper,
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
string message)
|
string message)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.ValidationMessageFor(expression, message, htmlAttributes: null, tag: null);
|
return htmlHelper.ValidationMessageFor(expression, message, htmlAttributes: null, tag: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -216,11 +259,21 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <c>null</c> if the <paramref name="expression"/> is valid and client-side validation is disabled.
|
/// <c>null</c> if the <paramref name="expression"/> is valid and client-side validation is disabled.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static IHtmlContent ValidationMessageFor<TModel, TResult>(
|
public static IHtmlContent ValidationMessageFor<TModel, TResult>(
|
||||||
[NotNull] this IHtmlHelper<TModel> htmlHelper,
|
this IHtmlHelper<TModel> htmlHelper,
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
string message,
|
string message,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.ValidationMessageFor(expression, message, htmlAttributes, tag: null);
|
return htmlHelper.ValidationMessageFor(expression, message, htmlAttributes, tag: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -246,11 +299,21 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <paramref name="expression"/> is valid and client-side validation is disabled.
|
/// <paramref name="expression"/> is valid and client-side validation is disabled.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static IHtmlContent ValidationMessageFor<TModel, TResult>(
|
public static IHtmlContent ValidationMessageFor<TModel, TResult>(
|
||||||
[NotNull] this IHtmlHelper<TModel> htmlHelper,
|
this IHtmlHelper<TModel> htmlHelper,
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
string message,
|
string message,
|
||||||
string tag)
|
string tag)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.ValidationMessageFor(expression, message, htmlAttributes: null, tag: tag);
|
return htmlHelper.ValidationMessageFor(expression, message, htmlAttributes: null, tag: tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -263,8 +326,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// New <see cref="IHtmlContent"/> containing a <div> element wrapping the <ul> element.
|
/// New <see cref="IHtmlContent"/> containing a <div> element wrapping the <ul> element.
|
||||||
/// <see cref="HtmlString.Empty"/> if the current model is valid and client-side validation is disabled).
|
/// <see cref="HtmlString.Empty"/> if the current model is valid and client-side validation is disabled).
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static IHtmlContent ValidationSummary([NotNull] this IHtmlHelper htmlHelper)
|
public static IHtmlContent ValidationSummary(this IHtmlHelper htmlHelper)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.ValidationSummary(
|
return htmlHelper.ValidationSummary(
|
||||||
excludePropertyErrors: false,
|
excludePropertyErrors: false,
|
||||||
message: null,
|
message: null,
|
||||||
|
|
@ -284,8 +352,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// New <see cref="IHtmlContent"/> containing a <div> element wrapping the <ul> element.
|
/// New <see cref="IHtmlContent"/> containing a <div> element wrapping the <ul> element.
|
||||||
/// <see cref="HtmlString.Empty"/> if the current model is valid and client-side validation is disabled).
|
/// <see cref="HtmlString.Empty"/> if the current model is valid and client-side validation is disabled).
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static IHtmlContent ValidationSummary([NotNull] this IHtmlHelper htmlHelper, bool excludePropertyErrors)
|
public static IHtmlContent ValidationSummary(this IHtmlHelper htmlHelper, bool excludePropertyErrors)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.ValidationSummary(
|
return htmlHelper.ValidationSummary(
|
||||||
excludePropertyErrors,
|
excludePropertyErrors,
|
||||||
message: null,
|
message: null,
|
||||||
|
|
@ -305,8 +378,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <paramref name="message"/>) and the <ul> element. <see cref="HtmlString.Empty"/> if the current model
|
/// <paramref name="message"/>) and the <ul> element. <see cref="HtmlString.Empty"/> if the current model
|
||||||
/// is valid and client-side validation is disabled).
|
/// is valid and client-side validation is disabled).
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static IHtmlContent ValidationSummary([NotNull] this IHtmlHelper htmlHelper, string message)
|
public static IHtmlContent ValidationSummary(this IHtmlHelper htmlHelper, string message)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.ValidationSummary(
|
return htmlHelper.ValidationSummary(
|
||||||
excludePropertyErrors: false,
|
excludePropertyErrors: false,
|
||||||
message: message,
|
message: message,
|
||||||
|
|
@ -329,8 +407,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// and the <ul> element. <see cref="HtmlString.Empty"/> if the current model is valid and client-side
|
/// and the <ul> element. <see cref="HtmlString.Empty"/> if the current model is valid and client-side
|
||||||
/// validation is disabled).
|
/// validation is disabled).
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static IHtmlContent ValidationSummary([NotNull] this IHtmlHelper htmlHelper, string message, string tag)
|
public static IHtmlContent ValidationSummary(this IHtmlHelper htmlHelper, string message, string tag)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.ValidationSummary(
|
return htmlHelper.ValidationSummary(
|
||||||
excludePropertyErrors: false,
|
excludePropertyErrors: false,
|
||||||
message: message,
|
message: message,
|
||||||
|
|
@ -354,10 +437,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// is valid and client-side validation is disabled).
|
/// is valid and client-side validation is disabled).
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static IHtmlContent ValidationSummary(
|
public static IHtmlContent ValidationSummary(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
bool excludePropertyErrors,
|
bool excludePropertyErrors,
|
||||||
string message)
|
string message)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.ValidationSummary(
|
return htmlHelper.ValidationSummary(
|
||||||
excludePropertyErrors,
|
excludePropertyErrors,
|
||||||
message,
|
message,
|
||||||
|
|
@ -383,10 +471,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// is valid and client-side validation is disabled).
|
/// is valid and client-side validation is disabled).
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static IHtmlContent ValidationSummary(
|
public static IHtmlContent ValidationSummary(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string message,
|
string message,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.ValidationSummary(
|
return htmlHelper.ValidationSummary(
|
||||||
excludePropertyErrors: false,
|
excludePropertyErrors: false,
|
||||||
message: message,
|
message: message,
|
||||||
|
|
@ -415,11 +508,16 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// validation is disabled).
|
/// validation is disabled).
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static IHtmlContent ValidationSummary(
|
public static IHtmlContent ValidationSummary(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
string message,
|
string message,
|
||||||
object htmlAttributes,
|
object htmlAttributes,
|
||||||
string tag)
|
string tag)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.ValidationSummary(
|
return htmlHelper.ValidationSummary(
|
||||||
excludePropertyErrors: false,
|
excludePropertyErrors: false,
|
||||||
message: message,
|
message: message,
|
||||||
|
|
@ -446,11 +544,16 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// validation is disabled).
|
/// validation is disabled).
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static IHtmlContent ValidationSummary(
|
public static IHtmlContent ValidationSummary(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
bool excludePropertyErrors,
|
bool excludePropertyErrors,
|
||||||
string message,
|
string message,
|
||||||
string tag)
|
string tag)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.ValidationSummary(
|
return htmlHelper.ValidationSummary(
|
||||||
excludePropertyErrors,
|
excludePropertyErrors,
|
||||||
message,
|
message,
|
||||||
|
|
@ -479,11 +582,16 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// is valid and client-side validation is disabled).
|
/// is valid and client-side validation is disabled).
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static IHtmlContent ValidationSummary(
|
public static IHtmlContent ValidationSummary(
|
||||||
[NotNull] this IHtmlHelper htmlHelper,
|
this IHtmlHelper htmlHelper,
|
||||||
bool excludePropertyErrors,
|
bool excludePropertyErrors,
|
||||||
string message,
|
string message,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.ValidationSummary(excludePropertyErrors, message, htmlAttributes, tag: null);
|
return htmlHelper.ValidationSummary(excludePropertyErrors, message, htmlAttributes, tag: null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,6 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.Rendering
|
namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
{
|
{
|
||||||
|
|
@ -22,8 +20,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Converts the expression result to a <see cref="string"/> directly.
|
/// Converts the expression result to a <see cref="string"/> directly.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static string Value([NotNull] this IHtmlHelper htmlHelper, string expression)
|
public static string Value(this IHtmlHelper htmlHelper, string expression)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.Value(expression, format: null);
|
return htmlHelper.Value(expression, format: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -39,9 +42,19 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// Converts the <paramref name="expression"/> result to a <see cref="string"/> directly.
|
/// Converts the <paramref name="expression"/> result to a <see cref="string"/> directly.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static string ValueFor<TModel, TResult>(
|
public static string ValueFor<TModel, TResult>(
|
||||||
[NotNull] this IHtmlHelper<TModel> htmlHelper,
|
this IHtmlHelper<TModel> htmlHelper,
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression)
|
Expression<Func<TModel, TResult>> expression)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.ValueFor(expression, format: null);
|
return htmlHelper.ValueFor(expression, format: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -53,8 +66,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Converts the model value to a <see cref="string"/> directly.
|
/// Converts the model value to a <see cref="string"/> directly.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static string ValueForModel([NotNull] this IHtmlHelper htmlHelper)
|
public static string ValueForModel(this IHtmlHelper htmlHelper)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.Value(expression: null, format: null);
|
return htmlHelper.Value(expression: null, format: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -70,8 +88,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// Converts the model value to a <see cref="string"/> directly if
|
/// Converts the model value to a <see cref="string"/> directly if
|
||||||
/// <paramref name="format"/> is <c>null</c> or empty.
|
/// <paramref name="format"/> is <c>null</c> or empty.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static string ValueForModel([NotNull] this IHtmlHelper htmlHelper, string format)
|
public static string ValueForModel(this IHtmlHelper htmlHelper, string format)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return htmlHelper.Value(expression: null, format: format);
|
return htmlHelper.Value(expression: null, format: format);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Microsoft.AspNet.Html.Abstractions;
|
using Microsoft.AspNet.Html.Abstractions;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
using Microsoft.Framework.WebEncoders;
|
using Microsoft.Framework.WebEncoders;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.Rendering
|
namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
|
|
@ -36,8 +35,18 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public void WriteTo([NotNull] TextWriter writer, [NotNull] IHtmlEncoder encoder)
|
public void WriteTo(TextWriter writer, IHtmlEncoder encoder)
|
||||||
{
|
{
|
||||||
|
if (writer == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(writer));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (encoder == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(encoder));
|
||||||
|
}
|
||||||
|
|
||||||
writer.Write(_input);
|
writer.Write(_input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ using Microsoft.AspNet.Html.Abstractions;
|
||||||
using Microsoft.AspNet.Mvc.ModelBinding;
|
using Microsoft.AspNet.Mvc.ModelBinding;
|
||||||
using Microsoft.AspNet.Mvc.ModelBinding.Validation;
|
using Microsoft.AspNet.Mvc.ModelBinding.Validation;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
using Microsoft.AspNet.Mvc.ViewFeatures;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
using Microsoft.Framework.WebEncoders;
|
using Microsoft.Framework.WebEncoders;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.Rendering
|
namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
|
|
@ -86,7 +85,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the anchor element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the anchor element.</returns>
|
||||||
IHtmlContent ActionLink(
|
IHtmlContent ActionLink(
|
||||||
[NotNull] string linkText,
|
string linkText,
|
||||||
string actionName,
|
string actionName,
|
||||||
string controllerName,
|
string controllerName,
|
||||||
string protocol,
|
string protocol,
|
||||||
|
|
@ -360,7 +359,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// Fully-qualified expression name, ignoring the current model. Must not be <c>null</c>.
|
/// Fully-qualified expression name, ignoring the current model. Must not be <c>null</c>.
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>A <see cref="string"/> containing the element Id.</returns>
|
/// <returns>A <see cref="string"/> containing the element Id.</returns>
|
||||||
string GenerateIdFromName([NotNull] string fullName);
|
string GenerateIdFromName(string fullName);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns information about about client validation rules for the specified <paramref name="metadata"/> or
|
/// Returns information about about client validation rules for the specified <paramref name="metadata"/> or
|
||||||
|
|
@ -402,7 +401,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// Thrown if <paramref name="enumType"/> is not an <see cref="Enum"/> or if it has a
|
/// Thrown if <paramref name="enumType"/> is not an <see cref="Enum"/> or if it has a
|
||||||
/// <see cref="FlagsAttribute"/>.
|
/// <see cref="FlagsAttribute"/>.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
IEnumerable<SelectListItem> GetEnumSelectList([NotNull] Type enumType);
|
IEnumerable<SelectListItem> GetEnumSelectList(Type enumType);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns an <input> element of type "hidden" for the specified <paramref name="expression"/>.
|
/// Returns an <input> element of type "hidden" for the specified <paramref name="expression"/>.
|
||||||
|
|
@ -502,7 +501,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// A <see cref="Task"/> that on completion returns a new <see cref="HtmlString"/> containing
|
/// A <see cref="Task"/> that on completion returns a new <see cref="HtmlString"/> containing
|
||||||
/// the created HTML.
|
/// the created HTML.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
Task<IHtmlContent> PartialAsync([NotNull] string partialViewName, object model, ViewDataDictionary viewData);
|
Task<IHtmlContent> PartialAsync(string partialViewName, object model, ViewDataDictionary viewData);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns an <input> element of type "password" for the specified <paramref name="expression"/>.
|
/// Returns an <input> element of type "password" for the specified <paramref name="expression"/>.
|
||||||
|
|
@ -617,7 +616,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
/// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
Task RenderPartialAsync([NotNull] string partialViewName, object model, ViewDataDictionary viewData);
|
Task RenderPartialAsync(string partialViewName, object model, ViewDataDictionary viewData);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns an anchor (<a>) element that contains a URL path to the specified route.
|
/// Returns an anchor (<a>) element that contains a URL path to the specified route.
|
||||||
|
|
@ -639,7 +638,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the anchor element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the anchor element.</returns>
|
||||||
IHtmlContent RouteLink(
|
IHtmlContent RouteLink(
|
||||||
[NotNull] string linkText,
|
string linkText,
|
||||||
string routeName,
|
string routeName,
|
||||||
string protocol,
|
string protocol,
|
||||||
string hostName,
|
string hostName,
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ using System.Collections.Generic;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using Microsoft.AspNet.Html.Abstractions;
|
using Microsoft.AspNet.Html.Abstractions;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
using Microsoft.AspNet.Mvc.ViewFeatures;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.Rendering
|
namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
{
|
{
|
||||||
|
|
@ -55,7 +54,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// if the <see cref="bool"/> values is <c>true</c>; does not include the attribute otherwise.
|
/// if the <see cref="bool"/> values is <c>true</c>; does not include the attribute otherwise.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
IHtmlContent CheckBoxFor([NotNull] Expression<Func<TModel, bool>> expression, object htmlAttributes);
|
IHtmlContent CheckBoxFor(Expression<Func<TModel, bool>> expression, object htmlAttributes);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns HTML markup for the <paramref name="expression"/>, using a display template, specified HTML field
|
/// Returns HTML markup for the <paramref name="expression"/>, using a display template, specified HTML field
|
||||||
|
|
@ -80,7 +79,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <paramref name="expression"/> result.
|
/// <paramref name="expression"/> result.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
IHtmlContent DisplayFor<TResult>(
|
IHtmlContent DisplayFor<TResult>(
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
string templateName,
|
string templateName,
|
||||||
string htmlFieldName,
|
string htmlFieldName,
|
||||||
object additionalViewData);
|
object additionalViewData);
|
||||||
|
|
@ -91,7 +90,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <param name="expression">An expression to be evaluated against the current model.</param>
|
/// <param name="expression">An expression to be evaluated against the current model.</param>
|
||||||
/// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
|
/// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
|
||||||
/// <returns>A <see cref="string"/> containing the display name.</returns>
|
/// <returns>A <see cref="string"/> containing the display name.</returns>
|
||||||
string DisplayNameFor<TResult>([NotNull] Expression<Func<TModel, TResult>> expression);
|
string DisplayNameFor<TResult>(Expression<Func<TModel, TResult>> expression);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the display name for the specified <paramref name="expression"/>
|
/// Returns the display name for the specified <paramref name="expression"/>
|
||||||
|
|
@ -102,7 +101,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
|
/// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
|
||||||
/// <returns>A <see cref="string"/> containing the display name.</returns>
|
/// <returns>A <see cref="string"/> containing the display name.</returns>
|
||||||
string DisplayNameForInnerType<TModelItem, TResult>(
|
string DisplayNameForInnerType<TModelItem, TResult>(
|
||||||
[NotNull] Expression<Func<TModelItem, TResult>> expression);
|
Expression<Func<TModelItem, TResult>> expression);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the simple display text for the specified <paramref name="expression"/>.
|
/// Returns the simple display text for the specified <paramref name="expression"/>.
|
||||||
|
|
@ -114,7 +113,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// If the <paramref name="expression"/> result is <c>null</c>, returns
|
/// If the <paramref name="expression"/> result is <c>null</c>, returns
|
||||||
/// <see cref="ModelBinding.ModelMetadata.NullDisplayText"/>.
|
/// <see cref="ModelBinding.ModelMetadata.NullDisplayText"/>.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
string DisplayTextFor<TResult>([NotNull] Expression<Func<TModel, TResult>> expression);
|
string DisplayTextFor<TResult>(Expression<Func<TModel, TResult>> expression);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a single-selection HTML <select> element for the <paramref name="expression"/>, using the
|
/// Returns a single-selection HTML <select> element for the <paramref name="expression"/>, using the
|
||||||
|
|
@ -140,7 +139,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// representation of the <paramref name="expression"/> to set element's "id" attribute.
|
/// representation of the <paramref name="expression"/> to set element's "id" attribute.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
IHtmlContent DropDownListFor<TResult>(
|
IHtmlContent DropDownListFor<TResult>(
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
IEnumerable<SelectListItem> selectList,
|
IEnumerable<SelectListItem> selectList,
|
||||||
string optionLabel,
|
string optionLabel,
|
||||||
object htmlAttributes);
|
object htmlAttributes);
|
||||||
|
|
@ -168,7 +167,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// elements for each property in the <paramref name="expression"/> result.
|
/// elements for each property in the <paramref name="expression"/> result.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
IHtmlContent EditorFor<TResult>(
|
IHtmlContent EditorFor<TResult>(
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
string templateName,
|
string templateName,
|
||||||
string htmlFieldName,
|
string htmlFieldName,
|
||||||
object additionalViewData);
|
object additionalViewData);
|
||||||
|
|
@ -210,7 +209,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </list>
|
/// </list>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
IHtmlContent HiddenFor<TResult>(
|
IHtmlContent HiddenFor<TResult>(
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
object htmlAttributes);
|
object htmlAttributes);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -219,7 +218,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <param name="expression">An expression to be evaluated against the current model.</param>
|
/// <param name="expression">An expression to be evaluated against the current model.</param>
|
||||||
/// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
|
/// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
|
||||||
/// <returns>A <see cref="string"/> containing the element Id.</returns>
|
/// <returns>A <see cref="string"/> containing the element Id.</returns>
|
||||||
string IdFor<TResult>([NotNull] Expression<Func<TModel, TResult>> expression);
|
string IdFor<TResult>(Expression<Func<TModel, TResult>> expression);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a <label> element for the specified <paramref name="expression"/>.
|
/// Returns a <label> element for the specified <paramref name="expression"/>.
|
||||||
|
|
@ -233,7 +232,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
|
/// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
|
||||||
/// <returns>A new <see cref="IHtmlContent"/> containing the <label> element.</returns>
|
/// <returns>A new <see cref="IHtmlContent"/> containing the <label> element.</returns>
|
||||||
IHtmlContent LabelFor<TResult>(
|
IHtmlContent LabelFor<TResult>(
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
string labelText,
|
string labelText,
|
||||||
object htmlAttributes);
|
object htmlAttributes);
|
||||||
|
|
||||||
|
|
@ -258,7 +257,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// representation of the <paramref name="expression"/> to set element's "id" attribute.
|
/// representation of the <paramref name="expression"/> to set element's "id" attribute.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
IHtmlContent ListBoxFor<TResult>(
|
IHtmlContent ListBoxFor<TResult>(
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
IEnumerable<SelectListItem> selectList,
|
IEnumerable<SelectListItem> selectList,
|
||||||
object htmlAttributes);
|
object htmlAttributes);
|
||||||
|
|
||||||
|
|
@ -268,7 +267,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <param name="expression">An expression to be evaluated against the current model.</param>
|
/// <param name="expression">An expression to be evaluated against the current model.</param>
|
||||||
/// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
|
/// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
|
||||||
/// <returns>A <see cref="string"/> containing the element name.</returns>
|
/// <returns>A <see cref="string"/> containing the element name.</returns>
|
||||||
string NameFor<TResult>([NotNull] Expression<Func<TModel, TResult>> expression);
|
string NameFor<TResult>(Expression<Func<TModel, TResult>> expression);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns an <input> element of type "password" for the specified <paramref name="expression"/>.
|
/// Returns an <input> element of type "password" for the specified <paramref name="expression"/>.
|
||||||
|
|
@ -297,7 +296,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </list>
|
/// </list>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
IHtmlContent PasswordFor<TResult>(
|
IHtmlContent PasswordFor<TResult>(
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
object htmlAttributes);
|
object htmlAttributes);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -337,8 +336,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
IHtmlContent RadioButtonFor<TResult>(
|
IHtmlContent RadioButtonFor<TResult>(
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
[NotNull] object value,
|
object value,
|
||||||
object htmlAttributes);
|
object htmlAttributes);
|
||||||
|
|
||||||
/// <inheritdoc cref="IHtmlHelper.Raw(object)"/>
|
/// <inheritdoc cref="IHtmlHelper.Raw(object)"/>
|
||||||
|
|
@ -378,7 +377,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </list>
|
/// </list>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
IHtmlContent TextAreaFor<TResult>(
|
IHtmlContent TextAreaFor<TResult>(
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
int rows,
|
int rows,
|
||||||
int columns,
|
int columns,
|
||||||
object htmlAttributes);
|
object htmlAttributes);
|
||||||
|
|
@ -418,7 +417,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// </list>
|
/// </list>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
IHtmlContent TextBoxFor<TResult>(
|
IHtmlContent TextBoxFor<TResult>(
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
string format,
|
string format,
|
||||||
object htmlAttributes);
|
object htmlAttributes);
|
||||||
|
|
||||||
|
|
@ -446,7 +445,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <paramref name="expression"/> is valid and client-side validation is disabled.
|
/// <paramref name="expression"/> is valid and client-side validation is disabled.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
IHtmlContent ValidationMessageFor<TResult>(
|
IHtmlContent ValidationMessageFor<TResult>(
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
string message,
|
string message,
|
||||||
object htmlAttributes,
|
object htmlAttributes,
|
||||||
string tag);
|
string tag);
|
||||||
|
|
@ -465,7 +464,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <paramref name="format"/> is <c>null</c> or empty.
|
/// <paramref name="format"/> is <c>null</c> or empty.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
string ValueFor<TResult>(
|
string ValueFor<TResult>(
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
string format);
|
string format);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.Rendering
|
namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
|
|
@ -24,6 +23,6 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <param name="value">The value to serialize as JSON.</param>
|
/// <param name="value">The value to serialize as JSON.</param>
|
||||||
/// <param name="serializerSettings">The <see cref="JsonSerializerSettings"/> to be used by the serializer.</param>
|
/// <param name="serializerSettings">The <see cref="JsonSerializerSettings"/> to be used by the serializer.</param>
|
||||||
/// <returns>A new <see cref="HtmlString"/> containing the serialized JSON.</returns>
|
/// <returns>A new <see cref="HtmlString"/> containing the serialized JSON.</returns>
|
||||||
HtmlString Serialize(object value, [NotNull] JsonSerializerSettings serializerSettings);
|
HtmlString Serialize(object value, JsonSerializerSettings serializerSettings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
using Microsoft.AspNet.Mvc.ViewFeatures;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.Rendering
|
namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
{
|
{
|
||||||
|
|
@ -15,28 +14,44 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
{
|
{
|
||||||
private IList<SelectListGroup> _groups;
|
private IList<SelectListGroup> _groups;
|
||||||
|
|
||||||
public MultiSelectList([NotNull] IEnumerable items)
|
public MultiSelectList(IEnumerable items)
|
||||||
: this(items, selectedValues: null)
|
: this(items, selectedValues: null)
|
||||||
{
|
{
|
||||||
|
if (items == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(items));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public MultiSelectList([NotNull] IEnumerable items, IEnumerable selectedValues)
|
public MultiSelectList(IEnumerable items, IEnumerable selectedValues)
|
||||||
: this(items, dataValueField: null, dataTextField: null, selectedValues: selectedValues)
|
: this(items, dataValueField: null, dataTextField: null, selectedValues: selectedValues)
|
||||||
{
|
{
|
||||||
|
if (items == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(items));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public MultiSelectList([NotNull] IEnumerable items, string dataValueField, string dataTextField)
|
public MultiSelectList(IEnumerable items, string dataValueField, string dataTextField)
|
||||||
: this(items, dataValueField, dataTextField, selectedValues: null)
|
: this(items, dataValueField, dataTextField, selectedValues: null)
|
||||||
{
|
{
|
||||||
|
if (items == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(items));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public MultiSelectList(
|
public MultiSelectList(
|
||||||
[NotNull] IEnumerable items,
|
IEnumerable items,
|
||||||
string dataValueField,
|
string dataValueField,
|
||||||
string dataTextField,
|
string dataTextField,
|
||||||
IEnumerable selectedValues)
|
IEnumerable selectedValues)
|
||||||
: this(items, dataValueField, dataTextField, selectedValues, dataGroupField: null)
|
: this(items, dataValueField, dataTextField, selectedValues, dataGroupField: null)
|
||||||
{
|
{
|
||||||
|
if (items == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(items));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -53,12 +68,17 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <param name="dataGroupField">The data group field. Used to match the Group property of the corresponding
|
/// <param name="dataGroupField">The data group field. Used to match the Group property of the corresponding
|
||||||
/// <see cref="SelectListItem"/>.</param>
|
/// <see cref="SelectListItem"/>.</param>
|
||||||
public MultiSelectList(
|
public MultiSelectList(
|
||||||
[NotNull] IEnumerable items,
|
IEnumerable items,
|
||||||
string dataValueField,
|
string dataValueField,
|
||||||
string dataTextField,
|
string dataTextField,
|
||||||
IEnumerable selectedValues,
|
IEnumerable selectedValues,
|
||||||
string dataGroupField)
|
string dataGroupField)
|
||||||
{
|
{
|
||||||
|
if (items == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(items));
|
||||||
|
}
|
||||||
|
|
||||||
Items = items;
|
Items = items;
|
||||||
DataValueField = dataValueField;
|
DataValueField = dataValueField;
|
||||||
DataTextField = dataTextField;
|
DataTextField = dataTextField;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
using Microsoft.AspNet.Mvc.ViewFeatures;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.Rendering
|
namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
{
|
{
|
||||||
|
|
@ -12,8 +11,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
private readonly ViewContext _viewContext;
|
private readonly ViewContext _viewContext;
|
||||||
private bool _disposed;
|
private bool _disposed;
|
||||||
|
|
||||||
public MvcForm([NotNull] ViewContext viewContext)
|
public MvcForm(ViewContext viewContext)
|
||||||
{
|
{
|
||||||
|
if (viewContext == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewContext));
|
||||||
|
}
|
||||||
|
|
||||||
_viewContext = viewContext;
|
_viewContext = viewContext;
|
||||||
|
|
||||||
// Push the new FormContext; GenerateEndForm() does the corresponding pop.
|
// Push the new FormContext; GenerateEndForm() does the corresponding pop.
|
||||||
|
|
|
||||||
|
|
@ -1,35 +1,52 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.Rendering
|
namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
{
|
{
|
||||||
public class SelectList : MultiSelectList
|
public class SelectList : MultiSelectList
|
||||||
{
|
{
|
||||||
public SelectList([NotNull] IEnumerable items)
|
public SelectList(IEnumerable items)
|
||||||
: this(items, selectedValue: null)
|
: this(items, selectedValue: null)
|
||||||
{
|
{
|
||||||
|
if (items == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(items));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SelectList([NotNull] IEnumerable items, object selectedValue)
|
public SelectList(IEnumerable items, object selectedValue)
|
||||||
: this(items, dataValueField: null, dataTextField: null, selectedValue: selectedValue)
|
: this(items, dataValueField: null, dataTextField: null, selectedValue: selectedValue)
|
||||||
{
|
{
|
||||||
|
if (items == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(items));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SelectList([NotNull] IEnumerable items, string dataValueField, string dataTextField)
|
public SelectList(IEnumerable items, string dataValueField, string dataTextField)
|
||||||
: this(items, dataValueField, dataTextField, selectedValue: null)
|
: this(items, dataValueField, dataTextField, selectedValue: null)
|
||||||
{
|
{
|
||||||
|
if (items == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(items));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SelectList(
|
public SelectList(
|
||||||
[NotNull] IEnumerable items,
|
IEnumerable items,
|
||||||
string dataValueField,
|
string dataValueField,
|
||||||
string dataTextField,
|
string dataTextField,
|
||||||
object selectedValue)
|
object selectedValue)
|
||||||
: base(items, dataValueField, dataTextField, ToEnumerable(selectedValue))
|
: base(items, dataValueField, dataTextField, ToEnumerable(selectedValue))
|
||||||
{
|
{
|
||||||
|
if (items == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(items));
|
||||||
|
}
|
||||||
|
|
||||||
SelectedValue = selectedValue;
|
SelectedValue = selectedValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -47,13 +64,18 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <param name="dataGroupField">The data group field. Used to match the Group property of the corresponding
|
/// <param name="dataGroupField">The data group field. Used to match the Group property of the corresponding
|
||||||
/// <see cref="SelectListItem"/>.</param>
|
/// <see cref="SelectListItem"/>.</param>
|
||||||
public SelectList(
|
public SelectList(
|
||||||
[NotNull] IEnumerable items,
|
IEnumerable items,
|
||||||
string dataValueField,
|
string dataValueField,
|
||||||
string dataTextField,
|
string dataTextField,
|
||||||
object selectedValue,
|
object selectedValue,
|
||||||
string dataGroupField)
|
string dataGroupField)
|
||||||
: base(items, dataValueField, dataTextField, ToEnumerable(selectedValue), dataGroupField)
|
: base(items, dataValueField, dataTextField, ToEnumerable(selectedValue), dataGroupField)
|
||||||
{
|
{
|
||||||
|
if (items == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(items));
|
||||||
|
}
|
||||||
|
|
||||||
SelectedValue = selectedValue;
|
SelectedValue = selectedValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -71,8 +71,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// Valid HTML 4.01 "id" attribute for an element with the given <paramref name="name"/>.
|
/// Valid HTML 4.01 "id" attribute for an element with the given <paramref name="name"/>.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
/// <remarks>Valid "id" attributes are defined in http://www.w3.org/TR/html401/types.html#type-id</remarks>
|
/// <remarks>Valid "id" attributes are defined in http://www.w3.org/TR/html401/types.html#type-id</remarks>
|
||||||
public static string CreateSanitizedId(string name, [NotNull] string invalidCharReplacement)
|
public static string CreateSanitizedId(string name, string invalidCharReplacement)
|
||||||
{
|
{
|
||||||
|
if (invalidCharReplacement == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(invalidCharReplacement));
|
||||||
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(name))
|
if (string.IsNullOrEmpty(name))
|
||||||
{
|
{
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
|
|
@ -127,8 +132,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
return stringBuffer.ToString();
|
return stringBuffer.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateId(string name, [NotNull] string idAttributeDotReplacement)
|
public void GenerateId(string name, string idAttributeDotReplacement)
|
||||||
{
|
{
|
||||||
|
if (idAttributeDotReplacement == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(idAttributeDotReplacement));
|
||||||
|
}
|
||||||
|
|
||||||
if (!Attributes.ContainsKey("id"))
|
if (!Attributes.ContainsKey("id"))
|
||||||
{
|
{
|
||||||
var sanitizedId = CreateSanitizedId(name, idAttributeDotReplacement);
|
var sanitizedId = CreateSanitizedId(name, idAttributeDotReplacement);
|
||||||
|
|
|
||||||
|
|
@ -1,36 +1,54 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Mvc.Rendering;
|
|
||||||
using Microsoft.AspNet.Mvc.ViewComponents;
|
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.Rendering
|
namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
{
|
{
|
||||||
public static class ViewComponentHelperExtensions
|
public static class ViewComponentHelperExtensions
|
||||||
{
|
{
|
||||||
public static HtmlString Invoke<TComponent>([NotNull] this IViewComponentHelper helper,
|
public static HtmlString Invoke<TComponent>(this IViewComponentHelper helper,
|
||||||
params object[] args)
|
params object[] args)
|
||||||
{
|
{
|
||||||
|
if (helper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(helper));
|
||||||
|
}
|
||||||
|
|
||||||
return helper.Invoke(typeof(TComponent), args);
|
return helper.Invoke(typeof(TComponent), args);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RenderInvoke<TComponent>([NotNull] this IViewComponentHelper helper,
|
public static void RenderInvoke<TComponent>(this IViewComponentHelper helper,
|
||||||
params object[] args)
|
params object[] args)
|
||||||
{
|
{
|
||||||
|
if (helper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(helper));
|
||||||
|
}
|
||||||
|
|
||||||
helper.RenderInvoke(typeof(TComponent), args);
|
helper.RenderInvoke(typeof(TComponent), args);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Task<HtmlString> InvokeAsync<TComponent>([NotNull] this IViewComponentHelper helper,
|
public static Task<HtmlString> InvokeAsync<TComponent>(this IViewComponentHelper helper,
|
||||||
params object[] args)
|
params object[] args)
|
||||||
{
|
{
|
||||||
|
if (helper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(helper));
|
||||||
|
}
|
||||||
|
|
||||||
return helper.InvokeAsync(typeof(TComponent), args);
|
return helper.InvokeAsync(typeof(TComponent), args);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Task RenderInvokeAsync<TComponent>([NotNull] this IViewComponentHelper helper,
|
public static Task RenderInvokeAsync<TComponent>(this IViewComponentHelper helper,
|
||||||
params object[] args)
|
params object[] args)
|
||||||
{
|
{
|
||||||
|
if (helper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(helper));
|
||||||
|
}
|
||||||
|
|
||||||
return helper.RenderInvokeAsync(typeof(TComponent), args);
|
return helper.RenderInvokeAsync(typeof(TComponent), args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Microsoft.AspNet.Mvc.ModelBinding;
|
using Microsoft.AspNet.Mvc.ModelBinding;
|
||||||
using Microsoft.AspNet.Mvc.ViewEngines;
|
using Microsoft.AspNet.Mvc.ViewEngines;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
using Microsoft.AspNet.Mvc.ViewFeatures;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.Rendering
|
namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
{
|
{
|
||||||
|
|
@ -40,14 +40,44 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <param name="tempData">The <see cref="ITempDataDictionary"/>.</param>
|
/// <param name="tempData">The <see cref="ITempDataDictionary"/>.</param>
|
||||||
/// <param name="writer">The <see cref="TextWriter"/> to render output to.</param>
|
/// <param name="writer">The <see cref="TextWriter"/> to render output to.</param>
|
||||||
public ViewContext(
|
public ViewContext(
|
||||||
[NotNull] ActionContext actionContext,
|
ActionContext actionContext,
|
||||||
[NotNull] IView view,
|
IView view,
|
||||||
[NotNull] ViewDataDictionary viewData,
|
ViewDataDictionary viewData,
|
||||||
[NotNull] ITempDataDictionary tempData,
|
ITempDataDictionary tempData,
|
||||||
[NotNull] TextWriter writer,
|
TextWriter writer,
|
||||||
[NotNull] HtmlHelperOptions htmlHelperOptions)
|
HtmlHelperOptions htmlHelperOptions)
|
||||||
: base(actionContext)
|
: base(actionContext)
|
||||||
{
|
{
|
||||||
|
if (actionContext == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(actionContext));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (view == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(view));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (viewData == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewData));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tempData == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(tempData));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (writer == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(writer));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (htmlHelperOptions == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelperOptions));
|
||||||
|
}
|
||||||
|
|
||||||
View = view;
|
View = view;
|
||||||
ViewData = viewData;
|
ViewData = viewData;
|
||||||
TempData = tempData;
|
TempData = tempData;
|
||||||
|
|
@ -68,12 +98,32 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <param name="viewData">The <see cref="ViewDataDictionary"/>.</param>
|
/// <param name="viewData">The <see cref="ViewDataDictionary"/>.</param>
|
||||||
/// <param name="writer">The <see cref="TextWriter"/> to render output to.</param>
|
/// <param name="writer">The <see cref="TextWriter"/> to render output to.</param>
|
||||||
public ViewContext(
|
public ViewContext(
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
[NotNull] IView view,
|
IView view,
|
||||||
[NotNull] ViewDataDictionary viewData,
|
ViewDataDictionary viewData,
|
||||||
[NotNull] TextWriter writer)
|
TextWriter writer)
|
||||||
: base(viewContext)
|
: base(viewContext)
|
||||||
{
|
{
|
||||||
|
if (viewContext == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewContext));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (view == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(view));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (viewData == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewData));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (writer == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(writer));
|
||||||
|
}
|
||||||
|
|
||||||
_formContext = viewContext.FormContext;
|
_formContext = viewContext.FormContext;
|
||||||
ClientValidationEnabled = viewContext.ClientValidationEnabled;
|
ClientValidationEnabled = viewContext.ClientValidationEnabled;
|
||||||
Html5DateRenderingMode = viewContext.Html5DateRenderingMode;
|
Html5DateRenderingMode = viewContext.Html5DateRenderingMode;
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ using System;
|
||||||
using Microsoft.AspNet.Diagnostics;
|
using Microsoft.AspNet.Diagnostics;
|
||||||
using Microsoft.AspNet.Http.Features;
|
using Microsoft.AspNet.Http.Features;
|
||||||
using Microsoft.AspNet.Mvc.Filters;
|
using Microsoft.AspNet.Mvc.Filters;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc
|
namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
|
|
@ -16,13 +15,22 @@ namespace Microsoft.AspNet.Mvc
|
||||||
public class SkipStatusCodePagesAttribute : Attribute, IResourceFilter
|
public class SkipStatusCodePagesAttribute : Attribute, IResourceFilter
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public void OnResourceExecuted([NotNull] ResourceExecutedContext context)
|
public void OnResourceExecuted(ResourceExecutedContext context)
|
||||||
{
|
{
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(context));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public void OnResourceExecuting([NotNull] ResourceExecutingContext context)
|
public void OnResourceExecuting(ResourceExecutingContext context)
|
||||||
{
|
{
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(context));
|
||||||
|
}
|
||||||
|
|
||||||
var statusCodeFeature = context.HttpContext.Features.Get<IStatusCodePagesFeature>();
|
var statusCodeFeature = context.HttpContext.Features.Get<IStatusCodePagesFeature>();
|
||||||
if (statusCodeFeature != null)
|
if (statusCodeFeature != null)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,16 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Security.Principal;
|
using System.Security.Principal;
|
||||||
using Microsoft.AspNet.Http;
|
using Microsoft.AspNet.Http;
|
||||||
using Microsoft.AspNet.Mvc.ModelBinding;
|
using Microsoft.AspNet.Mvc.ModelBinding;
|
||||||
using Microsoft.AspNet.Mvc.Rendering;
|
using Microsoft.AspNet.Mvc.Rendering;
|
||||||
using Microsoft.AspNet.Mvc.Routing;
|
|
||||||
using Microsoft.AspNet.Mvc.ViewComponents;
|
using Microsoft.AspNet.Mvc.ViewComponents;
|
||||||
using Microsoft.AspNet.Mvc.ViewEngines;
|
using Microsoft.AspNet.Mvc.ViewEngines;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
using Microsoft.AspNet.Mvc.ViewFeatures;
|
||||||
using Microsoft.AspNet.Routing;
|
using Microsoft.AspNet.Routing;
|
||||||
using Microsoft.Framework.DependencyInjection;
|
using Microsoft.Framework.DependencyInjection;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc
|
namespace Microsoft.AspNet.Mvc
|
||||||
|
|
@ -114,10 +113,13 @@ namespace Microsoft.AspNet.Mvc
|
||||||
|
|
||||||
return _url;
|
return _url;
|
||||||
}
|
}
|
||||||
|
|
||||||
[param: NotNull]
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
if (value == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(value));
|
||||||
|
}
|
||||||
|
|
||||||
_url = value;
|
_url = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -135,10 +137,13 @@ namespace Microsoft.AspNet.Mvc
|
||||||
|
|
||||||
return _viewComponentContext;
|
return _viewComponentContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
[param: NotNull]
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
if (value == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(value));
|
||||||
|
}
|
||||||
|
|
||||||
_viewComponentContext = value;
|
_viewComponentContext = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -181,10 +186,13 @@ namespace Microsoft.AspNet.Mvc
|
||||||
|
|
||||||
return _viewEngine;
|
return _viewEngine;
|
||||||
}
|
}
|
||||||
|
|
||||||
[param: NotNull]
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
if (value == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(value));
|
||||||
|
}
|
||||||
|
|
||||||
_viewEngine = value;
|
_viewEngine = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -194,8 +202,13 @@ namespace Microsoft.AspNet.Mvc
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="content">The content, will be HTML encoded before output.</param>
|
/// <param name="content">The content, will be HTML encoded before output.</param>
|
||||||
/// <returns>A <see cref="ContentViewComponentResult"/>.</returns>
|
/// <returns>A <see cref="ContentViewComponentResult"/>.</returns>
|
||||||
public ContentViewComponentResult Content([NotNull] string content)
|
public ContentViewComponentResult Content(string content)
|
||||||
{
|
{
|
||||||
|
if (content == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(content));
|
||||||
|
}
|
||||||
|
|
||||||
return new ContentViewComponentResult(content);
|
return new ContentViewComponentResult(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -218,8 +231,13 @@ namespace Microsoft.AspNet.Mvc
|
||||||
/// <returns>A <see cref="JsonViewComponentResult"/>.</returns>
|
/// <returns>A <see cref="JsonViewComponentResult"/>.</returns>
|
||||||
/// <remarks>Callers should cache an instance of <see cref="JsonSerializerSettings"/> to avoid
|
/// <remarks>Callers should cache an instance of <see cref="JsonSerializerSettings"/> to avoid
|
||||||
/// recreating cached data with each call.</remarks>
|
/// recreating cached data with each call.</remarks>
|
||||||
public JsonViewComponentResult Json(object value, [NotNull] JsonSerializerSettings serializerSettings)
|
public JsonViewComponentResult Json(object value, JsonSerializerSettings serializerSettings)
|
||||||
{
|
{
|
||||||
|
if (serializerSettings == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(serializerSettings));
|
||||||
|
}
|
||||||
|
|
||||||
return new JsonViewComponentResult(value, serializerSettings);
|
return new JsonViewComponentResult(value, serializerSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Mvc.ModelBinding;
|
using Microsoft.AspNet.Mvc.ModelBinding;
|
||||||
using Microsoft.AspNet.Mvc.Rendering;
|
using Microsoft.AspNet.Mvc.Rendering;
|
||||||
using Microsoft.AspNet.Mvc.ViewComponents;
|
|
||||||
using Microsoft.AspNet.Mvc.ViewEngines;
|
using Microsoft.AspNet.Mvc.ViewEngines;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
using Microsoft.AspNet.Mvc.ViewFeatures;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures.Internal;
|
using Microsoft.AspNet.Mvc.ViewFeatures.Internal;
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Mvc.Rendering;
|
using Microsoft.AspNet.Mvc.Rendering;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewComponents
|
namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
{
|
{
|
||||||
|
|
@ -26,8 +26,13 @@ namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
/// Initializes a new <see cref="ContentViewComponentResult"/>.
|
/// Initializes a new <see cref="ContentViewComponentResult"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="content">Content to write. The content be HTML encoded when output.</param>
|
/// <param name="content">Content to write. The content be HTML encoded when output.</param>
|
||||||
public ContentViewComponentResult([NotNull] string content)
|
public ContentViewComponentResult(string content)
|
||||||
{
|
{
|
||||||
|
if (content == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(content));
|
||||||
|
}
|
||||||
|
|
||||||
Content = content;
|
Content = content;
|
||||||
EncodedContent = new HtmlString(WebUtility.HtmlEncode(content));
|
EncodedContent = new HtmlString(WebUtility.HtmlEncode(content));
|
||||||
}
|
}
|
||||||
|
|
@ -39,8 +44,13 @@ namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
/// Content to write. The content is treated as already HTML encoded, and no further encoding
|
/// Content to write. The content is treated as already HTML encoded, and no further encoding
|
||||||
/// will be performed.
|
/// will be performed.
|
||||||
/// </param>
|
/// </param>
|
||||||
public ContentViewComponentResult([NotNull] HtmlString encodedContent)
|
public ContentViewComponentResult(HtmlString encodedContent)
|
||||||
{
|
{
|
||||||
|
if (encodedContent == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(encodedContent));
|
||||||
|
}
|
||||||
|
|
||||||
EncodedContent = encodedContent;
|
EncodedContent = encodedContent;
|
||||||
Content = WebUtility.HtmlDecode(encodedContent.ToString());
|
Content = WebUtility.HtmlDecode(encodedContent.ToString());
|
||||||
}
|
}
|
||||||
|
|
@ -59,8 +69,13 @@ namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
/// Writes the <see cref="EncodedContent"/>.
|
/// Writes the <see cref="EncodedContent"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="context">The <see cref="ViewComponentContext"/>.</param>
|
/// <param name="context">The <see cref="ViewComponentContext"/>.</param>
|
||||||
public void Execute([NotNull] ViewComponentContext context)
|
public void Execute(ViewComponentContext context)
|
||||||
{
|
{
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(context));
|
||||||
|
}
|
||||||
|
|
||||||
context.Writer.Write(EncodedContent.ToString());
|
context.Writer.Write(EncodedContent.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -69,8 +84,13 @@ namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="context">The <see cref="ViewComponentContext"/>.</param>
|
/// <param name="context">The <see cref="ViewComponentContext"/>.</param>
|
||||||
/// <returns>A completed <see cref="Task"/>.</returns>
|
/// <returns>A completed <see cref="Task"/>.</returns>
|
||||||
public Task ExecuteAsync([NotNull] ViewComponentContext context)
|
public Task ExecuteAsync(ViewComponentContext context)
|
||||||
{
|
{
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(context));
|
||||||
|
}
|
||||||
|
|
||||||
return context.Writer.WriteAsync(EncodedContent.ToString());
|
return context.Writer.WriteAsync(EncodedContent.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,18 @@ namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public virtual void Activate([NotNull] object viewComponent, [NotNull] ViewComponentContext context)
|
public virtual void Activate(object viewComponent, ViewComponentContext context)
|
||||||
{
|
{
|
||||||
|
if (viewComponent == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewComponent));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(context));
|
||||||
|
}
|
||||||
|
|
||||||
var propertiesToActivate = _injectActions.GetOrAdd(
|
var propertiesToActivate = _injectActions.GetOrAdd(
|
||||||
viewComponent.GetType(),
|
viewComponent.GetType(),
|
||||||
_getPropertiesToActivate);
|
_getPropertiesToActivate);
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Microsoft.AspNet.Mvc.Infrastructure;
|
using Microsoft.AspNet.Mvc.Infrastructure;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewComponents
|
namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
{
|
{
|
||||||
|
|
@ -53,8 +53,13 @@ namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// <c>true</c> if <paramref name="typeInfo"/>represents a View Component class, otherwise <c>false</c>.
|
/// <c>true</c> if <paramref name="typeInfo"/>represents a View Component class, otherwise <c>false</c>.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
protected virtual bool IsViewComponentType([NotNull] TypeInfo typeInfo)
|
protected virtual bool IsViewComponentType(TypeInfo typeInfo)
|
||||||
{
|
{
|
||||||
|
if (typeInfo == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(typeInfo));
|
||||||
|
}
|
||||||
|
|
||||||
return ViewComponentConventions.IsComponent(typeInfo);
|
return ViewComponentConventions.IsComponent(typeInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Mvc.Rendering;
|
using Microsoft.AspNet.Mvc.Rendering;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
using Microsoft.AspNet.Mvc.ViewFeatures;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures.Internal;
|
using Microsoft.AspNet.Mvc.ViewFeatures.Internal;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewComponents
|
namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
{
|
{
|
||||||
|
|
@ -19,22 +18,47 @@ namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
private ViewContext _viewContext;
|
private ViewContext _viewContext;
|
||||||
|
|
||||||
public DefaultViewComponentHelper(
|
public DefaultViewComponentHelper(
|
||||||
[NotNull] IViewComponentDescriptorCollectionProvider descriptorProvider,
|
IViewComponentDescriptorCollectionProvider descriptorProvider,
|
||||||
[NotNull] IViewComponentSelector selector,
|
IViewComponentSelector selector,
|
||||||
[NotNull] IViewComponentInvokerFactory invokerFactory)
|
IViewComponentInvokerFactory invokerFactory)
|
||||||
{
|
{
|
||||||
|
if (descriptorProvider == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(descriptorProvider));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selector == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(selector));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (invokerFactory == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(invokerFactory));
|
||||||
|
}
|
||||||
|
|
||||||
_descriptorProvider = descriptorProvider;
|
_descriptorProvider = descriptorProvider;
|
||||||
_selector = selector;
|
_selector = selector;
|
||||||
_invokerFactory = invokerFactory;
|
_invokerFactory = invokerFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Contextualize([NotNull] ViewContext viewContext)
|
public void Contextualize(ViewContext viewContext)
|
||||||
{
|
{
|
||||||
|
if (viewContext == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewContext));
|
||||||
|
}
|
||||||
|
|
||||||
_viewContext = viewContext;
|
_viewContext = viewContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HtmlString Invoke([NotNull] string name, params object[] arguments)
|
public HtmlString Invoke(string name, params object[] arguments)
|
||||||
{
|
{
|
||||||
|
if (name == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(name));
|
||||||
|
}
|
||||||
|
|
||||||
var descriptor = SelectComponent(name);
|
var descriptor = SelectComponent(name);
|
||||||
|
|
||||||
using (var writer = new StringWriter())
|
using (var writer = new StringWriter())
|
||||||
|
|
@ -44,8 +68,13 @@ namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public HtmlString Invoke([NotNull] Type componentType, params object[] arguments)
|
public HtmlString Invoke(Type componentType, params object[] arguments)
|
||||||
{
|
{
|
||||||
|
if (componentType == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(componentType));
|
||||||
|
}
|
||||||
|
|
||||||
var descriptor = SelectComponent(componentType);
|
var descriptor = SelectComponent(componentType);
|
||||||
|
|
||||||
using (var writer = new StringWriter())
|
using (var writer = new StringWriter())
|
||||||
|
|
@ -55,20 +84,35 @@ namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RenderInvoke([NotNull] string name, params object[] arguments)
|
public void RenderInvoke(string name, params object[] arguments)
|
||||||
{
|
{
|
||||||
|
if (name == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(name));
|
||||||
|
}
|
||||||
|
|
||||||
var descriptor = SelectComponent(name);
|
var descriptor = SelectComponent(name);
|
||||||
InvokeCore(_viewContext.Writer, descriptor, arguments);
|
InvokeCore(_viewContext.Writer, descriptor, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RenderInvoke([NotNull] Type componentType, params object[] arguments)
|
public void RenderInvoke(Type componentType, params object[] arguments)
|
||||||
{
|
{
|
||||||
|
if (componentType == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(componentType));
|
||||||
|
}
|
||||||
|
|
||||||
var descriptor = SelectComponent(componentType);
|
var descriptor = SelectComponent(componentType);
|
||||||
InvokeCore(_viewContext.Writer, descriptor, arguments);
|
InvokeCore(_viewContext.Writer, descriptor, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<HtmlString> InvokeAsync([NotNull] string name, params object[] arguments)
|
public async Task<HtmlString> InvokeAsync(string name, params object[] arguments)
|
||||||
{
|
{
|
||||||
|
if (name == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(name));
|
||||||
|
}
|
||||||
|
|
||||||
var descriptor = SelectComponent(name);
|
var descriptor = SelectComponent(name);
|
||||||
|
|
||||||
using (var writer = new StringWriter())
|
using (var writer = new StringWriter())
|
||||||
|
|
@ -78,8 +122,13 @@ namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<HtmlString> InvokeAsync([NotNull] Type componentType, params object[] arguments)
|
public async Task<HtmlString> InvokeAsync(Type componentType, params object[] arguments)
|
||||||
{
|
{
|
||||||
|
if (componentType == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(componentType));
|
||||||
|
}
|
||||||
|
|
||||||
var descriptor = SelectComponent(componentType);
|
var descriptor = SelectComponent(componentType);
|
||||||
|
|
||||||
using (var writer = new StringWriter())
|
using (var writer = new StringWriter())
|
||||||
|
|
@ -89,14 +138,24 @@ namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task RenderInvokeAsync([NotNull] string name, params object[] arguments)
|
public Task RenderInvokeAsync(string name, params object[] arguments)
|
||||||
{
|
{
|
||||||
|
if (name == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(name));
|
||||||
|
}
|
||||||
|
|
||||||
var descriptor = SelectComponent(name);
|
var descriptor = SelectComponent(name);
|
||||||
return InvokeCoreAsync(_viewContext.Writer, descriptor, arguments);
|
return InvokeCoreAsync(_viewContext.Writer, descriptor, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task RenderInvokeAsync([NotNull] Type componentType, params object[] arguments)
|
public Task RenderInvokeAsync(Type componentType, params object[] arguments)
|
||||||
{
|
{
|
||||||
|
if (componentType == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(componentType));
|
||||||
|
}
|
||||||
|
|
||||||
var descriptor = SelectComponent(componentType);
|
var descriptor = SelectComponent(componentType);
|
||||||
return InvokeCoreAsync(_viewContext.Writer, descriptor, arguments);
|
return InvokeCoreAsync(_viewContext.Writer, descriptor, arguments);
|
||||||
}
|
}
|
||||||
|
|
@ -128,10 +187,20 @@ namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task InvokeCoreAsync(
|
private Task InvokeCoreAsync(
|
||||||
[NotNull] TextWriter writer,
|
TextWriter writer,
|
||||||
[NotNull] ViewComponentDescriptor descriptor,
|
ViewComponentDescriptor descriptor,
|
||||||
object[] arguments)
|
object[] arguments)
|
||||||
{
|
{
|
||||||
|
if (writer == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(writer));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (descriptor == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(descriptor));
|
||||||
|
}
|
||||||
|
|
||||||
var context = new ViewComponentContext(descriptor, arguments, _viewContext, writer);
|
var context = new ViewComponentContext(descriptor, arguments, _viewContext, writer);
|
||||||
|
|
||||||
var invoker = _invokerFactory.CreateInstance(context);
|
var invoker = _invokerFactory.CreateInstance(context);
|
||||||
|
|
@ -145,10 +214,20 @@ namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InvokeCore(
|
private void InvokeCore(
|
||||||
[NotNull] TextWriter writer,
|
TextWriter writer,
|
||||||
[NotNull] ViewComponentDescriptor descriptor,
|
ViewComponentDescriptor descriptor,
|
||||||
object[] arguments)
|
object[] arguments)
|
||||||
{
|
{
|
||||||
|
if (writer == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(writer));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (descriptor == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(descriptor));
|
||||||
|
}
|
||||||
|
|
||||||
var context = new ViewComponentContext(descriptor, arguments, _viewContext, writer);
|
var context = new ViewComponentContext(descriptor, arguments, _viewContext, writer);
|
||||||
|
|
||||||
var invoker = _invokerFactory.CreateInstance(context);
|
var invoker = _invokerFactory.CreateInstance(context);
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ using Microsoft.AspNet.Mvc.Controllers;
|
||||||
using Microsoft.AspNet.Mvc.Infrastructure;
|
using Microsoft.AspNet.Mvc.Infrastructure;
|
||||||
using Microsoft.AspNet.Mvc.Rendering;
|
using Microsoft.AspNet.Mvc.Rendering;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
using Microsoft.AspNet.Mvc.ViewFeatures;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewComponents
|
namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
{
|
{
|
||||||
|
|
@ -19,15 +18,30 @@ namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
private readonly IViewComponentActivator _viewComponentActivator;
|
private readonly IViewComponentActivator _viewComponentActivator;
|
||||||
|
|
||||||
public DefaultViewComponentInvoker(
|
public DefaultViewComponentInvoker(
|
||||||
[NotNull] ITypeActivatorCache typeActivatorCache,
|
ITypeActivatorCache typeActivatorCache,
|
||||||
[NotNull] IViewComponentActivator viewComponentActivator)
|
IViewComponentActivator viewComponentActivator)
|
||||||
{
|
{
|
||||||
|
if (typeActivatorCache == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(typeActivatorCache));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (viewComponentActivator == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewComponentActivator));
|
||||||
|
}
|
||||||
|
|
||||||
_typeActivatorCache = typeActivatorCache;
|
_typeActivatorCache = typeActivatorCache;
|
||||||
_viewComponentActivator = viewComponentActivator;
|
_viewComponentActivator = viewComponentActivator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Invoke([NotNull] ViewComponentContext context)
|
public void Invoke(ViewComponentContext context)
|
||||||
{
|
{
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(context));
|
||||||
|
}
|
||||||
|
|
||||||
var method = ViewComponentMethodSelector.FindSyncMethod(
|
var method = ViewComponentMethodSelector.FindSyncMethod(
|
||||||
context.ViewComponentDescriptor.Type.GetTypeInfo(),
|
context.ViewComponentDescriptor.Type.GetTypeInfo(),
|
||||||
context.Arguments);
|
context.Arguments);
|
||||||
|
|
@ -41,8 +55,13 @@ namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
result.Execute(context);
|
result.Execute(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task InvokeAsync([NotNull] ViewComponentContext context)
|
public async Task InvokeAsync(ViewComponentContext context)
|
||||||
{
|
{
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(context));
|
||||||
|
}
|
||||||
|
|
||||||
IViewComponentResult result;
|
IViewComponentResult result;
|
||||||
|
|
||||||
var asyncMethod = ViewComponentMethodSelector.FindAsyncMethod(
|
var asyncMethod = ViewComponentMethodSelector.FindAsyncMethod(
|
||||||
|
|
@ -74,20 +93,35 @@ namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
await result.ExecuteAsync(context);
|
await result.ExecuteAsync(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
private object CreateComponent([NotNull] ViewComponentContext context)
|
private object CreateComponent(ViewComponentContext context)
|
||||||
{
|
{
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(context));
|
||||||
|
}
|
||||||
|
|
||||||
var services = context.ViewContext.HttpContext.RequestServices;
|
var services = context.ViewContext.HttpContext.RequestServices;
|
||||||
var component = _typeActivatorCache.CreateInstance<object>(
|
var component = _typeActivatorCache.CreateInstance<object>(
|
||||||
services,
|
services,
|
||||||
context.ViewComponentDescriptor.Type);
|
context.ViewComponentDescriptor.Type);
|
||||||
_viewComponentActivator.Activate(component, context);
|
_viewComponentActivator.Activate(component, context);
|
||||||
return component;
|
return component;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<IViewComponentResult> InvokeAsyncCore(
|
private async Task<IViewComponentResult> InvokeAsyncCore(
|
||||||
[NotNull] MethodInfo method,
|
MethodInfo method,
|
||||||
[NotNull] ViewComponentContext context)
|
ViewComponentContext context)
|
||||||
{
|
{
|
||||||
|
if (method == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(method));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(context));
|
||||||
|
}
|
||||||
|
|
||||||
var component = CreateComponent(context);
|
var component = CreateComponent(context);
|
||||||
|
|
||||||
var result = await ControllerActionExecutor.ExecuteAsync(method, component, context.Arguments);
|
var result = await ControllerActionExecutor.ExecuteAsync(method, component, context.Arguments);
|
||||||
|
|
@ -95,8 +129,18 @@ namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
return CoerceToViewComponentResult(result);
|
return CoerceToViewComponentResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IViewComponentResult InvokeSyncCore([NotNull] MethodInfo method, [NotNull] ViewComponentContext context)
|
public IViewComponentResult InvokeSyncCore(MethodInfo method, ViewComponentContext context)
|
||||||
{
|
{
|
||||||
|
if (method == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(method));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(context));
|
||||||
|
}
|
||||||
|
|
||||||
var component = CreateComponent(context);
|
var component = CreateComponent(context);
|
||||||
|
|
||||||
object result = null;
|
object result = null;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
using Microsoft.AspNet.Mvc.Infrastructure;
|
using Microsoft.AspNet.Mvc.Infrastructure;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewComponents
|
namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
{
|
{
|
||||||
|
|
@ -23,8 +23,13 @@ namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
// We don't currently make use of the descriptor or the arguments here (they are available on the context).
|
// We don't currently make use of the descriptor or the arguments here (they are available on the context).
|
||||||
// We might do this some day to cache which method we select, so resist the urge to 'clean' this without
|
// We might do this some day to cache which method we select, so resist the urge to 'clean' this without
|
||||||
// considering that possibility.
|
// considering that possibility.
|
||||||
public IViewComponentInvoker CreateInstance([NotNull] ViewComponentContext context)
|
public IViewComponentInvoker CreateInstance(ViewComponentContext context)
|
||||||
{
|
{
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(context));
|
||||||
|
}
|
||||||
|
|
||||||
return new DefaultViewComponentInvoker(
|
return new DefaultViewComponentInvoker(
|
||||||
_typeActivatorCache,
|
_typeActivatorCache,
|
||||||
_viewComponentActivator);
|
_viewComponentActivator);
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
using Microsoft.AspNet.Mvc.ViewFeatures;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewComponents
|
namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
{
|
{
|
||||||
|
|
@ -28,8 +27,13 @@ namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public ViewComponentDescriptor SelectComponent([NotNull] string componentName)
|
public ViewComponentDescriptor SelectComponent(string componentName)
|
||||||
{
|
{
|
||||||
|
if (componentName == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(componentName));
|
||||||
|
}
|
||||||
|
|
||||||
var collection = _descriptorProvider.ViewComponents;
|
var collection = _descriptorProvider.ViewComponents;
|
||||||
if (_cache == null || _cache.Version != collection.Version)
|
if (_cache == null || _cache.Version != collection.Version)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,13 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewComponents
|
namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
{
|
{
|
||||||
public interface IViewComponentInvoker
|
public interface IViewComponentInvoker
|
||||||
{
|
{
|
||||||
void Invoke([NotNull] ViewComponentContext context);
|
void Invoke(ViewComponentContext context);
|
||||||
|
|
||||||
Task InvokeAsync([NotNull] ViewComponentContext context);
|
Task InvokeAsync(ViewComponentContext context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,10 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewComponents
|
namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
{
|
{
|
||||||
public interface IViewComponentInvokerFactory
|
public interface IViewComponentInvokerFactory
|
||||||
{
|
{
|
||||||
IViewComponentInvoker CreateInstance([NotNull] ViewComponentContext context);
|
IViewComponentInvoker CreateInstance(ViewComponentContext context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewComponents
|
namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -15,6 +13,6 @@ namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="componentName">The View Component name.</param>
|
/// <param name="componentName">The View Component name.</param>
|
||||||
/// <returns>A <see cref="ViewComponentDescriptor"/>, or <c>null</c> if no match is found.</returns>
|
/// <returns>A <see cref="ViewComponentDescriptor"/>, or <c>null</c> if no match is found.</returns>
|
||||||
ViewComponentDescriptor SelectComponent([NotNull] string componentName);
|
ViewComponentDescriptor SelectComponent(string componentName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.Framework.DependencyInjection;
|
using Microsoft.Framework.DependencyInjection;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
using Microsoft.Framework.OptionsModel;
|
using Microsoft.Framework.OptionsModel;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
|
@ -31,8 +31,13 @@ namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
/// <param name="value">The value to format as JSON text.</param>
|
/// <param name="value">The value to format as JSON text.</param>
|
||||||
/// <param name="serializerSettings">The <see cref="JsonSerializerSettings"/> to be used by
|
/// <param name="serializerSettings">The <see cref="JsonSerializerSettings"/> to be used by
|
||||||
/// the formatter.</param>
|
/// the formatter.</param>
|
||||||
public JsonViewComponentResult(object value, [NotNull] JsonSerializerSettings serializerSettings)
|
public JsonViewComponentResult(object value, JsonSerializerSettings serializerSettings)
|
||||||
{
|
{
|
||||||
|
if (serializerSettings == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(serializerSettings));
|
||||||
|
}
|
||||||
|
|
||||||
Value = value;
|
Value = value;
|
||||||
_serializerSettings = serializerSettings;
|
_serializerSettings = serializerSettings;
|
||||||
}
|
}
|
||||||
|
|
@ -46,8 +51,13 @@ namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
/// Renders JSON text to the output.
|
/// Renders JSON text to the output.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="context">The <see cref="ViewComponentContext"/>.</param>
|
/// <param name="context">The <see cref="ViewComponentContext"/>.</param>
|
||||||
public void Execute([NotNull] ViewComponentContext context)
|
public void Execute(ViewComponentContext context)
|
||||||
{
|
{
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(context));
|
||||||
|
}
|
||||||
|
|
||||||
var serializerSettings = _serializerSettings;
|
var serializerSettings = _serializerSettings;
|
||||||
if (serializerSettings == null)
|
if (serializerSettings == null)
|
||||||
{
|
{
|
||||||
|
|
@ -73,8 +83,13 @@ namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="context">The <see cref="ViewComponentContext"/>.</param>
|
/// <param name="context">The <see cref="ViewComponentContext"/>.</param>
|
||||||
/// <returns>A completed <see cref="Task"/>.</returns>
|
/// <returns>A completed <see cref="Task"/>.</returns>
|
||||||
public Task ExecuteAsync([NotNull] ViewComponentContext context)
|
public Task ExecuteAsync(ViewComponentContext context)
|
||||||
{
|
{
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(context));
|
||||||
|
}
|
||||||
|
|
||||||
Execute(context);
|
Execute(context);
|
||||||
return Task.FromResult(true);
|
return Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Microsoft.AspNet.Mvc.Rendering;
|
using Microsoft.AspNet.Mvc.Rendering;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
using Microsoft.AspNet.Mvc.ViewFeatures;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewComponents
|
namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
{
|
{
|
||||||
|
|
@ -36,11 +36,31 @@ namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
/// <param name="viewContext">The <see cref="ViewContext"/>.</param>
|
/// <param name="viewContext">The <see cref="ViewContext"/>.</param>
|
||||||
/// <param name="writer">The <see cref="TextWriter"/> for writing output.</param>
|
/// <param name="writer">The <see cref="TextWriter"/> for writing output.</param>
|
||||||
public ViewComponentContext(
|
public ViewComponentContext(
|
||||||
[NotNull] ViewComponentDescriptor viewComponentDescriptor,
|
ViewComponentDescriptor viewComponentDescriptor,
|
||||||
[NotNull] object[] arguments,
|
object[] arguments,
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
[NotNull] TextWriter writer)
|
TextWriter writer)
|
||||||
{
|
{
|
||||||
|
if (viewComponentDescriptor == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewComponentDescriptor));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arguments == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(arguments));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (viewContext == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewContext));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (writer == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(writer));
|
||||||
|
}
|
||||||
|
|
||||||
ViewComponentDescriptor = viewComponentDescriptor;
|
ViewComponentDescriptor = viewComponentDescriptor;
|
||||||
Arguments = arguments;
|
Arguments = arguments;
|
||||||
|
|
||||||
|
|
@ -48,7 +68,7 @@ namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
// aren't visible in the calling view.
|
// aren't visible in the calling view.
|
||||||
ViewContext = new ViewContext(
|
ViewContext = new ViewContext(
|
||||||
viewContext,
|
viewContext,
|
||||||
viewContext.View,
|
viewContext.View,
|
||||||
new ViewDataDictionary(viewContext.ViewData),
|
new ViewDataDictionary(viewContext.ViewData),
|
||||||
writer);
|
writer);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewComponents
|
namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
{
|
{
|
||||||
|
|
@ -11,8 +10,13 @@ namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
{
|
{
|
||||||
private const string ViewComponentSuffix = "ViewComponent";
|
private const string ViewComponentSuffix = "ViewComponent";
|
||||||
|
|
||||||
public static string GetComponentName([NotNull] TypeInfo componentType)
|
public static string GetComponentName(TypeInfo componentType)
|
||||||
{
|
{
|
||||||
|
if (componentType == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(componentType));
|
||||||
|
}
|
||||||
|
|
||||||
var attribute = componentType.GetCustomAttribute<ViewComponentAttribute>();
|
var attribute = componentType.GetCustomAttribute<ViewComponentAttribute>();
|
||||||
if (attribute != null && !string.IsNullOrEmpty(attribute.Name))
|
if (attribute != null && !string.IsNullOrEmpty(attribute.Name))
|
||||||
{
|
{
|
||||||
|
|
@ -30,8 +34,13 @@ namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
return GetShortNameByConvention(componentType);
|
return GetShortNameByConvention(componentType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetComponentFullName([NotNull] TypeInfo componentType)
|
public static string GetComponentFullName(TypeInfo componentType)
|
||||||
{
|
{
|
||||||
|
if (componentType == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(componentType));
|
||||||
|
}
|
||||||
|
|
||||||
var attribute = componentType.GetCustomAttribute<ViewComponentAttribute>();
|
var attribute = componentType.GetCustomAttribute<ViewComponentAttribute>();
|
||||||
if (!string.IsNullOrEmpty(attribute?.Name))
|
if (!string.IsNullOrEmpty(attribute?.Name))
|
||||||
{
|
{
|
||||||
|
|
@ -63,8 +72,13 @@ namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsComponent([NotNull] TypeInfo typeInfo)
|
public static bool IsComponent(TypeInfo typeInfo)
|
||||||
{
|
{
|
||||||
|
if (typeInfo == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(typeInfo));
|
||||||
|
}
|
||||||
|
|
||||||
if (!typeInfo.IsClass ||
|
if (!typeInfo.IsClass ||
|
||||||
!typeInfo.IsPublic ||
|
!typeInfo.IsPublic ||
|
||||||
typeInfo.IsAbstract ||
|
typeInfo.IsAbstract ||
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewComponents
|
namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
{
|
{
|
||||||
|
|
@ -16,8 +16,13 @@ namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="items">The result of view component discovery</param>
|
/// <param name="items">The result of view component discovery</param>
|
||||||
/// <param name="version">The unique version of discovered view components.</param>
|
/// <param name="version">The unique version of discovered view components.</param>
|
||||||
public ViewComponentDescriptorCollection([NotNull] IEnumerable<ViewComponentDescriptor> items, int version)
|
public ViewComponentDescriptorCollection(IEnumerable<ViewComponentDescriptor> items, int version)
|
||||||
{
|
{
|
||||||
|
if (items == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(items));
|
||||||
|
}
|
||||||
|
|
||||||
Items = new List<ViewComponentDescriptor>(items);
|
Items = new List<ViewComponentDescriptor>(items);
|
||||||
Version = version;
|
Version = version;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ using System.Linq.Expressions;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
using Microsoft.AspNet.Mvc.ViewFeatures;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewComponents
|
namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
{
|
{
|
||||||
|
|
@ -15,8 +14,13 @@ namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
public const string AsyncMethodName = "InvokeAsync";
|
public const string AsyncMethodName = "InvokeAsync";
|
||||||
public const string SyncMethodName = "Invoke";
|
public const string SyncMethodName = "Invoke";
|
||||||
|
|
||||||
public static MethodInfo FindAsyncMethod([NotNull] TypeInfo componentType, object[] args)
|
public static MethodInfo FindAsyncMethod(TypeInfo componentType, object[] args)
|
||||||
{
|
{
|
||||||
|
if (componentType == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(componentType));
|
||||||
|
}
|
||||||
|
|
||||||
var method = GetMethod(componentType, args, AsyncMethodName);
|
var method = GetMethod(componentType, args, AsyncMethodName);
|
||||||
if (method == null)
|
if (method == null)
|
||||||
{
|
{
|
||||||
|
|
@ -33,8 +37,13 @@ namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MethodInfo FindSyncMethod([NotNull] TypeInfo componentType, object[] args)
|
public static MethodInfo FindSyncMethod(TypeInfo componentType, object[] args)
|
||||||
{
|
{
|
||||||
|
if (componentType == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(componentType));
|
||||||
|
}
|
||||||
|
|
||||||
var method = GetMethod(componentType, args, SyncMethodName);
|
var method = GetMethod(componentType, args, SyncMethodName);
|
||||||
if (method == null)
|
if (method == null)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ using Microsoft.AspNet.Mvc.Rendering;
|
||||||
using Microsoft.AspNet.Mvc.ViewEngines;
|
using Microsoft.AspNet.Mvc.ViewEngines;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
using Microsoft.AspNet.Mvc.ViewFeatures;
|
||||||
using Microsoft.Framework.DependencyInjection;
|
using Microsoft.Framework.DependencyInjection;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewComponents
|
namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
{
|
{
|
||||||
|
|
@ -49,8 +48,13 @@ namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// This method synchronously calls and blocks on <see cref="ExecuteAsync(ViewComponentContext)"/>.
|
/// This method synchronously calls and blocks on <see cref="ExecuteAsync(ViewComponentContext)"/>.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public void Execute([NotNull] ViewComponentContext context)
|
public void Execute(ViewComponentContext context)
|
||||||
{
|
{
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(context));
|
||||||
|
}
|
||||||
|
|
||||||
var task = ExecuteAsync(context);
|
var task = ExecuteAsync(context);
|
||||||
task.GetAwaiter().GetResult();
|
task.GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
@ -61,8 +65,13 @@ namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="context">The <see cref="ViewComponentContext"/> for the current component execution.</param>
|
/// <param name="context">The <see cref="ViewComponentContext"/> for the current component execution.</param>
|
||||||
/// <returns>A <see cref="Task"/> which will complete when view rendering is completed.</returns>
|
/// <returns>A <see cref="Task"/> which will complete when view rendering is completed.</returns>
|
||||||
public async Task ExecuteAsync([NotNull] ViewComponentContext context)
|
public async Task ExecuteAsync(ViewComponentContext context)
|
||||||
{
|
{
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(context));
|
||||||
|
}
|
||||||
|
|
||||||
var viewEngine = ViewEngine ?? ResolveViewEngine(context);
|
var viewEngine = ViewEngine ?? ResolveViewEngine(context);
|
||||||
var viewData = ViewData ?? context.ViewData;
|
var viewData = ViewData ?? context.ViewData;
|
||||||
var isNullOrEmptyViewName = string.IsNullOrEmpty(ViewName);
|
var isNullOrEmptyViewName = string.IsNullOrEmpty(ViewName);
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
using Microsoft.Framework.OptionsModel;
|
using Microsoft.Framework.OptionsModel;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewEngines
|
namespace Microsoft.AspNet.Mvc.ViewEngines
|
||||||
|
|
@ -25,17 +25,37 @@ namespace Microsoft.AspNet.Mvc.ViewEngines
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public ViewEngineResult FindPartialView(
|
public ViewEngineResult FindPartialView(
|
||||||
[NotNull] ActionContext context,
|
ActionContext context,
|
||||||
[NotNull] string partialViewName)
|
string partialViewName)
|
||||||
{
|
{
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(context));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (partialViewName == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(partialViewName));
|
||||||
|
}
|
||||||
|
|
||||||
return FindView(context, partialViewName, partial: true);
|
return FindView(context, partialViewName, partial: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public ViewEngineResult FindView(
|
public ViewEngineResult FindView(
|
||||||
[NotNull] ActionContext context,
|
ActionContext context,
|
||||||
[NotNull] string viewName)
|
string viewName)
|
||||||
{
|
{
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(context));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (viewName == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewName));
|
||||||
|
}
|
||||||
|
|
||||||
return FindView(context, viewName, partial: false);
|
return FindView(context, viewName, partial: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Mvc.Rendering;
|
using Microsoft.AspNet.Mvc.Rendering;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewEngines
|
namespace Microsoft.AspNet.Mvc.ViewEngines
|
||||||
{
|
{
|
||||||
|
|
@ -22,6 +21,6 @@ namespace Microsoft.AspNet.Mvc.ViewEngines
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="context">The <see cref="ViewContext"/>.</param>
|
/// <param name="context">The <see cref="ViewContext"/>.</param>
|
||||||
/// <returns>A <see cref="Task"/> that on completion renders the view.</returns>
|
/// <returns>A <see cref="Task"/> that on completion renders the view.</returns>
|
||||||
Task RenderAsync([NotNull] ViewContext context);
|
Task RenderAsync(ViewContext context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
using Microsoft.AspNet.Mvc.ViewFeatures;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewEngines
|
namespace Microsoft.AspNet.Mvc.ViewEngines
|
||||||
{
|
{
|
||||||
|
|
@ -26,9 +25,19 @@ namespace Microsoft.AspNet.Mvc.ViewEngines
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ViewEngineResult NotFound(
|
public static ViewEngineResult NotFound(
|
||||||
[NotNull] string viewName,
|
string viewName,
|
||||||
[NotNull] IEnumerable<string> searchedLocations)
|
IEnumerable<string> searchedLocations)
|
||||||
{
|
{
|
||||||
|
if (viewName == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewName));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (searchedLocations == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(searchedLocations));
|
||||||
|
}
|
||||||
|
|
||||||
return new ViewEngineResult
|
return new ViewEngineResult
|
||||||
{
|
{
|
||||||
SearchedLocations = searchedLocations,
|
SearchedLocations = searchedLocations,
|
||||||
|
|
@ -36,8 +45,18 @@ namespace Microsoft.AspNet.Mvc.ViewEngines
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ViewEngineResult Found([NotNull] string viewName, [NotNull] IView view)
|
public static ViewEngineResult Found(string viewName, IView view)
|
||||||
{
|
{
|
||||||
|
if (viewName == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewName));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (view == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(view));
|
||||||
|
}
|
||||||
|
|
||||||
return new ViewEngineResult
|
return new ViewEngineResult
|
||||||
{
|
{
|
||||||
View = view,
|
View = view,
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewFeatures
|
namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
{
|
{
|
||||||
|
|
@ -17,8 +16,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
// If the provided expression is particularly obscure and the system doesn't know
|
// If the provided expression is particularly obscure and the system doesn't know
|
||||||
// how to handle it, we'll just compile the expression as normal.
|
// how to handle it, we'll just compile the expression as normal.
|
||||||
public static Func<TModel, TResult> Process<TModel, TResult>(
|
public static Func<TModel, TResult> Process<TModel, TResult>(
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression)
|
Expression<Func<TModel, TResult>> expression)
|
||||||
{
|
{
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
return Compiler<TModel, TResult>.Compile(expression);
|
return Compiler<TModel, TResult>.Compile(expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -32,8 +36,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
private static readonly ConcurrentDictionary<MemberInfo, Func<object, TResult>> _constMemberAccessCache =
|
private static readonly ConcurrentDictionary<MemberInfo, Func<object, TResult>> _constMemberAccessCache =
|
||||||
new ConcurrentDictionary<MemberInfo, Func<object, TResult>>();
|
new ConcurrentDictionary<MemberInfo, Func<object, TResult>>();
|
||||||
|
|
||||||
public static Func<TModel, TResult> Compile([NotNull] Expression<Func<TModel, TResult>> expression)
|
public static Func<TModel, TResult> Compile(Expression<Func<TModel, TResult>> expression)
|
||||||
{
|
{
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
return CompileFromIdentityFunc(expression)
|
return CompileFromIdentityFunc(expression)
|
||||||
?? CompileFromConstLookup(expression)
|
?? CompileFromConstLookup(expression)
|
||||||
?? CompileFromMemberAccess(expression)
|
?? CompileFromMemberAccess(expression)
|
||||||
|
|
@ -41,8 +50,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Func<TModel, TResult> CompileFromConstLookup(
|
private static Func<TModel, TResult> CompileFromConstLookup(
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression)
|
Expression<Func<TModel, TResult>> expression)
|
||||||
{
|
{
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
var constantExpression = expression.Body as ConstantExpression;
|
var constantExpression = expression.Body as ConstantExpression;
|
||||||
if (constantExpression != null)
|
if (constantExpression != null)
|
||||||
{
|
{
|
||||||
|
|
@ -56,8 +70,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Func<TModel, TResult> CompileFromIdentityFunc(
|
private static Func<TModel, TResult> CompileFromIdentityFunc(
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression)
|
Expression<Func<TModel, TResult>> expression)
|
||||||
{
|
{
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
if (expression.Body == expression.Parameters[0])
|
if (expression.Body == expression.Parameters[0])
|
||||||
{
|
{
|
||||||
// model => model
|
// model => model
|
||||||
|
|
@ -75,8 +94,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Func<TModel, TResult> CompileFromMemberAccess(
|
private static Func<TModel, TResult> CompileFromMemberAccess(
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression)
|
Expression<Func<TModel, TResult>> expression)
|
||||||
{
|
{
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
// Performance tests show that on the x64 platform, special-casing static member and
|
// Performance tests show that on the x64 platform, special-casing static member and
|
||||||
// captured local variable accesses is faster than letting the fingerprinting system
|
// captured local variable accesses is faster than letting the fingerprinting system
|
||||||
// handle them. On the x86 platform, the fingerprinting system is faster, but only
|
// handle them. On the x86 platform, the fingerprinting system is faster, but only
|
||||||
|
|
@ -118,8 +142,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Func<TModel, TResult> CompileSlow([NotNull] Expression<Func<TModel, TResult>> expression)
|
private static Func<TModel, TResult> CompileSlow(Expression<Func<TModel, TResult>> expression)
|
||||||
{
|
{
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
// fallback compilation system - just compile the expression directly
|
// fallback compilation system - just compile the expression directly
|
||||||
return expression.Compile();
|
return expression.Compile();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -280,7 +280,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
|
|
||||||
var valueDivTag = new TagBuilder("div");
|
var valueDivTag = new TagBuilder("div");
|
||||||
valueDivTag.AddCssClass("editor-field");
|
valueDivTag.AddCssClass("editor-field");
|
||||||
|
|
||||||
valueDivTag.InnerHtml.Append(templateBuilderResult);
|
valueDivTag.InnerHtml.Append(templateBuilderResult);
|
||||||
valueDivTag.InnerHtml.AppendEncoded(" ");
|
valueDivTag.InnerHtml.AppendEncoded(" ");
|
||||||
valueDivTag.InnerHtml.Append(htmlHelper.ValidationMessage(
|
valueDivTag.InnerHtml.Append(htmlHelper.ValidationMessage(
|
||||||
|
|
@ -365,13 +365,23 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
return GenerateTextBox(htmlHelper, inputType: "number");
|
return GenerateTextBox(htmlHelper, inputType: "number");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IHtmlContent FileInputTemplate([NotNull] IHtmlHelper htmlHelper)
|
public static IHtmlContent FileInputTemplate(IHtmlHelper htmlHelper)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
return GenerateTextBox(htmlHelper, inputType: "file");
|
return GenerateTextBox(htmlHelper, inputType: "file");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IHtmlContent FileCollectionInputTemplate([NotNull] IHtmlHelper htmlHelper)
|
public static IHtmlContent FileCollectionInputTemplate(IHtmlHelper htmlHelper)
|
||||||
{
|
{
|
||||||
|
if (htmlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
var htmlAttributes =
|
var htmlAttributes =
|
||||||
CreateHtmlAttributes(htmlHelper, className: "text-box single-line", inputType: "file");
|
CreateHtmlAttributes(htmlHelper, className: "text-box single-line", inputType: "file");
|
||||||
htmlAttributes["multiple"] = "multiple";
|
htmlAttributes["multiple"] = "multiple";
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@ using Microsoft.AspNet.Html.Abstractions;
|
||||||
using Microsoft.AspNet.Mvc.ModelBinding;
|
using Microsoft.AspNet.Mvc.ModelBinding;
|
||||||
using Microsoft.AspNet.Mvc.ModelBinding.Validation;
|
using Microsoft.AspNet.Mvc.ModelBinding.Validation;
|
||||||
using Microsoft.AspNet.Mvc.Rendering;
|
using Microsoft.AspNet.Mvc.Rendering;
|
||||||
using Microsoft.AspNet.Mvc.Routing;
|
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures.Internal;
|
using Microsoft.AspNet.Mvc.ViewFeatures.Internal;
|
||||||
using Microsoft.Framework.Internal;
|
using Microsoft.Framework.Internal;
|
||||||
using Microsoft.Framework.OptionsModel;
|
using Microsoft.Framework.OptionsModel;
|
||||||
|
|
@ -43,12 +42,37 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
/// <param name="urlHelper">The <see cref="IUrlHelper"/>.</param>
|
/// <param name="urlHelper">The <see cref="IUrlHelper"/>.</param>
|
||||||
/// <param name="htmlEncoder">The <see cref="IHtmlEncoder"/>.</param>
|
/// <param name="htmlEncoder">The <see cref="IHtmlEncoder"/>.</param>
|
||||||
public DefaultHtmlGenerator(
|
public DefaultHtmlGenerator(
|
||||||
[NotNull] IAntiforgery antiforgery,
|
IAntiforgery antiforgery,
|
||||||
[NotNull] IOptions<MvcViewOptions> optionsAccessor,
|
IOptions<MvcViewOptions> optionsAccessor,
|
||||||
[NotNull] IModelMetadataProvider metadataProvider,
|
IModelMetadataProvider metadataProvider,
|
||||||
[NotNull] IUrlHelper urlHelper,
|
IUrlHelper urlHelper,
|
||||||
[NotNull] IHtmlEncoder htmlEncoder)
|
IHtmlEncoder htmlEncoder)
|
||||||
{
|
{
|
||||||
|
if (antiforgery == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(antiforgery));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (optionsAccessor == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(optionsAccessor));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (metadataProvider == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(metadataProvider));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (urlHelper == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(urlHelper));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (htmlEncoder == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlEncoder));
|
||||||
|
}
|
||||||
|
|
||||||
_antiforgery = antiforgery;
|
_antiforgery = antiforgery;
|
||||||
var clientValidatorProviders = optionsAccessor.Value.ClientModelValidatorProviders;
|
var clientValidatorProviders = optionsAccessor.Value.ClientModelValidatorProviders;
|
||||||
_clientModelValidatorProvider = new CompositeClientModelValidatorProvider(clientValidatorProviders);
|
_clientModelValidatorProvider = new CompositeClientModelValidatorProvider(clientValidatorProviders);
|
||||||
|
|
@ -83,7 +107,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public virtual TagBuilder GenerateActionLink(
|
public virtual TagBuilder GenerateActionLink(
|
||||||
[NotNull] string linkText,
|
string linkText,
|
||||||
string actionName,
|
string actionName,
|
||||||
string controllerName,
|
string controllerName,
|
||||||
string protocol,
|
string protocol,
|
||||||
|
|
@ -92,25 +116,40 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
object routeValues,
|
object routeValues,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (linkText == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(linkText));
|
||||||
|
}
|
||||||
|
|
||||||
var url = _urlHelper.Action(actionName, controllerName, routeValues, protocol, hostname, fragment);
|
var url = _urlHelper.Action(actionName, controllerName, routeValues, protocol, hostname, fragment);
|
||||||
return GenerateLink(linkText, url, htmlAttributes);
|
return GenerateLink(linkText, url, htmlAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public virtual IHtmlContent GenerateAntiforgery([NotNull] ViewContext viewContext)
|
public virtual IHtmlContent GenerateAntiforgery(ViewContext viewContext)
|
||||||
{
|
{
|
||||||
|
if (viewContext == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewContext));
|
||||||
|
}
|
||||||
|
|
||||||
var tag = _antiforgery.GetHtml(viewContext.HttpContext);
|
var tag = _antiforgery.GetHtml(viewContext.HttpContext);
|
||||||
return new HtmlString(tag);
|
return new HtmlString(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public virtual TagBuilder GenerateCheckBox(
|
public virtual TagBuilder GenerateCheckBox(
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
ModelExplorer modelExplorer,
|
ModelExplorer modelExplorer,
|
||||||
string expression,
|
string expression,
|
||||||
bool? isChecked,
|
bool? isChecked,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (viewContext == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewContext));
|
||||||
|
}
|
||||||
|
|
||||||
if (modelExplorer != null)
|
if (modelExplorer != null)
|
||||||
{
|
{
|
||||||
// CheckBoxFor() case. That API does not support passing isChecked directly.
|
// CheckBoxFor() case. That API does not support passing isChecked directly.
|
||||||
|
|
@ -150,10 +189,15 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public virtual TagBuilder GenerateHiddenForCheckbox(
|
public virtual TagBuilder GenerateHiddenForCheckbox(
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
ModelExplorer modelExplorer,
|
ModelExplorer modelExplorer,
|
||||||
string expression)
|
string expression)
|
||||||
{
|
{
|
||||||
|
if (viewContext == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewContext));
|
||||||
|
}
|
||||||
|
|
||||||
var tagBuilder = new TagBuilder("input");
|
var tagBuilder = new TagBuilder("input");
|
||||||
tagBuilder.MergeAttribute("type", GetInputTypeString(InputType.Hidden));
|
tagBuilder.MergeAttribute("type", GetInputTypeString(InputType.Hidden));
|
||||||
tagBuilder.MergeAttribute("value", "false");
|
tagBuilder.MergeAttribute("value", "false");
|
||||||
|
|
@ -167,13 +211,18 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public virtual TagBuilder GenerateForm(
|
public virtual TagBuilder GenerateForm(
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
string actionName,
|
string actionName,
|
||||||
string controllerName,
|
string controllerName,
|
||||||
object routeValues,
|
object routeValues,
|
||||||
string method,
|
string method,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (viewContext == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewContext));
|
||||||
|
}
|
||||||
|
|
||||||
var defaultMethod = false;
|
var defaultMethod = false;
|
||||||
if (string.IsNullOrEmpty(method))
|
if (string.IsNullOrEmpty(method))
|
||||||
{
|
{
|
||||||
|
|
@ -203,12 +252,17 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public TagBuilder GenerateRouteForm(
|
public TagBuilder GenerateRouteForm(
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
string routeName,
|
string routeName,
|
||||||
object routeValues,
|
object routeValues,
|
||||||
string method,
|
string method,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (viewContext == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewContext));
|
||||||
|
}
|
||||||
|
|
||||||
var action =
|
var action =
|
||||||
_urlHelper.RouteUrl(routeName, values: routeValues, protocol: null, host: null, fragment: null);
|
_urlHelper.RouteUrl(routeName, values: routeValues, protocol: null, host: null, fragment: null);
|
||||||
|
|
||||||
|
|
@ -217,13 +271,18 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public virtual TagBuilder GenerateHidden(
|
public virtual TagBuilder GenerateHidden(
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
ModelExplorer modelExplorer,
|
ModelExplorer modelExplorer,
|
||||||
string expression,
|
string expression,
|
||||||
object value,
|
object value,
|
||||||
bool useViewData,
|
bool useViewData,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (viewContext == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewContext));
|
||||||
|
}
|
||||||
|
|
||||||
// Special-case opaque values and arbitrary binary data.
|
// Special-case opaque values and arbitrary binary data.
|
||||||
var byteArrayValue = value as byte[];
|
var byteArrayValue = value as byte[];
|
||||||
if (byteArrayValue != null)
|
if (byteArrayValue != null)
|
||||||
|
|
@ -248,12 +307,22 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public virtual TagBuilder GenerateLabel(
|
public virtual TagBuilder GenerateLabel(
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
[NotNull] ModelExplorer modelExplorer,
|
ModelExplorer modelExplorer,
|
||||||
string expression,
|
string expression,
|
||||||
string labelText,
|
string labelText,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (viewContext == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewContext));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (modelExplorer == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(modelExplorer));
|
||||||
|
}
|
||||||
|
|
||||||
var resolvedLabelText = labelText ??
|
var resolvedLabelText = labelText ??
|
||||||
modelExplorer.Metadata.DisplayName ??
|
modelExplorer.Metadata.DisplayName ??
|
||||||
modelExplorer.Metadata.PropertyName;
|
modelExplorer.Metadata.PropertyName;
|
||||||
|
|
@ -280,12 +349,17 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public virtual TagBuilder GeneratePassword(
|
public virtual TagBuilder GeneratePassword(
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
ModelExplorer modelExplorer,
|
ModelExplorer modelExplorer,
|
||||||
string expression,
|
string expression,
|
||||||
object value,
|
object value,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (viewContext == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewContext));
|
||||||
|
}
|
||||||
|
|
||||||
var htmlAttributeDictionary = GetHtmlAttributeDictionaryOrNull(htmlAttributes);
|
var htmlAttributeDictionary = GetHtmlAttributeDictionaryOrNull(htmlAttributes);
|
||||||
return GenerateInput(
|
return GenerateInput(
|
||||||
viewContext,
|
viewContext,
|
||||||
|
|
@ -303,13 +377,18 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public virtual TagBuilder GenerateRadioButton(
|
public virtual TagBuilder GenerateRadioButton(
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
ModelExplorer modelExplorer,
|
ModelExplorer modelExplorer,
|
||||||
string expression,
|
string expression,
|
||||||
object value,
|
object value,
|
||||||
bool? isChecked,
|
bool? isChecked,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (viewContext == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewContext));
|
||||||
|
}
|
||||||
|
|
||||||
var htmlAttributeDictionary = GetHtmlAttributeDictionaryOrNull(htmlAttributes);
|
var htmlAttributeDictionary = GetHtmlAttributeDictionaryOrNull(htmlAttributes);
|
||||||
if (modelExplorer == null)
|
if (modelExplorer == null)
|
||||||
{
|
{
|
||||||
|
|
@ -367,7 +446,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public virtual TagBuilder GenerateRouteLink(
|
public virtual TagBuilder GenerateRouteLink(
|
||||||
[NotNull] string linkText,
|
string linkText,
|
||||||
string routeName,
|
string routeName,
|
||||||
string protocol,
|
string protocol,
|
||||||
string hostName,
|
string hostName,
|
||||||
|
|
@ -375,13 +454,18 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
object routeValues,
|
object routeValues,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (linkText == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(linkText));
|
||||||
|
}
|
||||||
|
|
||||||
var url = _urlHelper.RouteUrl(routeName, routeValues, protocol, hostName, fragment);
|
var url = _urlHelper.RouteUrl(routeName, routeValues, protocol, hostName, fragment);
|
||||||
return GenerateLink(linkText, url, htmlAttributes);
|
return GenerateLink(linkText, url, htmlAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public TagBuilder GenerateSelect(
|
public TagBuilder GenerateSelect(
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
ModelExplorer modelExplorer,
|
ModelExplorer modelExplorer,
|
||||||
string optionLabel,
|
string optionLabel,
|
||||||
string expression,
|
string expression,
|
||||||
|
|
@ -389,6 +473,11 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
bool allowMultiple,
|
bool allowMultiple,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (viewContext == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewContext));
|
||||||
|
}
|
||||||
|
|
||||||
var currentValues = GetCurrentValues(viewContext, modelExplorer, expression, allowMultiple);
|
var currentValues = GetCurrentValues(viewContext, modelExplorer, expression, allowMultiple);
|
||||||
return GenerateSelect(
|
return GenerateSelect(
|
||||||
viewContext,
|
viewContext,
|
||||||
|
|
@ -403,7 +492,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public virtual TagBuilder GenerateSelect(
|
public virtual TagBuilder GenerateSelect(
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
ModelExplorer modelExplorer,
|
ModelExplorer modelExplorer,
|
||||||
string optionLabel,
|
string optionLabel,
|
||||||
string expression,
|
string expression,
|
||||||
|
|
@ -412,6 +501,11 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
bool allowMultiple,
|
bool allowMultiple,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (viewContext == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewContext));
|
||||||
|
}
|
||||||
|
|
||||||
var fullName = GetFullHtmlFieldName(viewContext, expression);
|
var fullName = GetFullHtmlFieldName(viewContext, expression);
|
||||||
if (string.IsNullOrEmpty(fullName))
|
if (string.IsNullOrEmpty(fullName))
|
||||||
{
|
{
|
||||||
|
|
@ -423,7 +517,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
nameof(IHtmlHelper<object>.EditorFor),
|
nameof(IHtmlHelper<object>.EditorFor),
|
||||||
"htmlFieldName"),
|
"htmlFieldName"),
|
||||||
nameof(expression));
|
nameof(expression));
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we got a null selectList, try to use ViewData to get the list of items.
|
// If we got a null selectList, try to use ViewData to get the list of items.
|
||||||
if (selectList == null)
|
if (selectList == null)
|
||||||
|
|
@ -468,13 +562,18 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public virtual TagBuilder GenerateTextArea(
|
public virtual TagBuilder GenerateTextArea(
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
ModelExplorer modelExplorer,
|
ModelExplorer modelExplorer,
|
||||||
string expression,
|
string expression,
|
||||||
int rows,
|
int rows,
|
||||||
int columns,
|
int columns,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (viewContext == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewContext));
|
||||||
|
}
|
||||||
|
|
||||||
if (rows < 0)
|
if (rows < 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentOutOfRangeException(nameof(rows), Resources.HtmlHelper_TextAreaParameterOutOfRange);
|
throw new ArgumentOutOfRangeException(nameof(rows), Resources.HtmlHelper_TextAreaParameterOutOfRange);
|
||||||
|
|
@ -545,13 +644,18 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public virtual TagBuilder GenerateTextBox(
|
public virtual TagBuilder GenerateTextBox(
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
ModelExplorer modelExplorer,
|
ModelExplorer modelExplorer,
|
||||||
string expression,
|
string expression,
|
||||||
object value,
|
object value,
|
||||||
string format,
|
string format,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (viewContext == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewContext));
|
||||||
|
}
|
||||||
|
|
||||||
var htmlAttributeDictionary = GetHtmlAttributeDictionaryOrNull(htmlAttributes);
|
var htmlAttributeDictionary = GetHtmlAttributeDictionaryOrNull(htmlAttributes);
|
||||||
return GenerateInput(
|
return GenerateInput(
|
||||||
viewContext,
|
viewContext,
|
||||||
|
|
@ -569,12 +673,17 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public virtual TagBuilder GenerateValidationMessage(
|
public virtual TagBuilder GenerateValidationMessage(
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
string expression,
|
string expression,
|
||||||
string message,
|
string message,
|
||||||
string tag,
|
string tag,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (viewContext == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewContext));
|
||||||
|
}
|
||||||
|
|
||||||
var fullName = GetFullHtmlFieldName(viewContext, expression);
|
var fullName = GetFullHtmlFieldName(viewContext, expression);
|
||||||
if (string.IsNullOrEmpty(fullName))
|
if (string.IsNullOrEmpty(fullName))
|
||||||
{
|
{
|
||||||
|
|
@ -649,12 +758,17 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public virtual TagBuilder GenerateValidationSummary(
|
public virtual TagBuilder GenerateValidationSummary(
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
bool excludePropertyErrors,
|
bool excludePropertyErrors,
|
||||||
string message,
|
string message,
|
||||||
string headerTag,
|
string headerTag,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (viewContext == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewContext));
|
||||||
|
}
|
||||||
|
|
||||||
var formContext = viewContext.ClientValidationEnabled ? viewContext.FormContext : null;
|
var formContext = viewContext.ClientValidationEnabled ? viewContext.FormContext : null;
|
||||||
if (viewContext.ViewData.ModelState.IsValid && (formContext == null || excludePropertyErrors))
|
if (viewContext.ViewData.ModelState.IsValid && (formContext == null || excludePropertyErrors))
|
||||||
{
|
{
|
||||||
|
|
@ -717,7 +831,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
{
|
{
|
||||||
tagBuilder.AddCssClass(HtmlHelper.ValidationSummaryCssClassName);
|
tagBuilder.AddCssClass(HtmlHelper.ValidationSummaryCssClassName);
|
||||||
}
|
}
|
||||||
|
|
||||||
tagBuilder.InnerHtml.Append(wrappedMessage);
|
tagBuilder.InnerHtml.Append(wrappedMessage);
|
||||||
tagBuilder.InnerHtml.Append(htmlSummary);
|
tagBuilder.InnerHtml.Append(htmlSummary);
|
||||||
|
|
||||||
|
|
@ -732,10 +846,15 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public IEnumerable<ModelClientValidationRule> GetClientValidationRules(
|
public IEnumerable<ModelClientValidationRule> GetClientValidationRules(
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
ModelExplorer modelExplorer,
|
ModelExplorer modelExplorer,
|
||||||
string expression)
|
string expression)
|
||||||
{
|
{
|
||||||
|
if (viewContext == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewContext));
|
||||||
|
}
|
||||||
|
|
||||||
modelExplorer = modelExplorer ??
|
modelExplorer = modelExplorer ??
|
||||||
ExpressionMetadataProvider.FromStringExpression(expression, viewContext.ViewData, _metadataProvider);
|
ExpressionMetadataProvider.FromStringExpression(expression, viewContext.ViewData, _metadataProvider);
|
||||||
var validationContext = new ClientModelValidationContext(
|
var validationContext = new ClientModelValidationContext(
|
||||||
|
|
@ -752,11 +871,16 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public virtual IReadOnlyCollection<string> GetCurrentValues(
|
public virtual IReadOnlyCollection<string> GetCurrentValues(
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
ModelExplorer modelExplorer,
|
ModelExplorer modelExplorer,
|
||||||
string expression,
|
string expression,
|
||||||
bool allowMultiple)
|
bool allowMultiple)
|
||||||
{
|
{
|
||||||
|
if (viewContext == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewContext));
|
||||||
|
}
|
||||||
|
|
||||||
var fullName = GetFullHtmlFieldName(viewContext, expression);
|
var fullName = GetFullHtmlFieldName(viewContext, expression);
|
||||||
if (string.IsNullOrEmpty(fullName))
|
if (string.IsNullOrEmpty(fullName))
|
||||||
{
|
{
|
||||||
|
|
@ -953,11 +1077,16 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
/// A <see cref="TagBuilder"/> instance for the </form> element.
|
/// A <see cref="TagBuilder"/> instance for the </form> element.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
protected virtual TagBuilder GenerateFormCore(
|
protected virtual TagBuilder GenerateFormCore(
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
string action,
|
string action,
|
||||||
string method,
|
string method,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (viewContext == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewContext));
|
||||||
|
}
|
||||||
|
|
||||||
var tagBuilder = new TagBuilder("form");
|
var tagBuilder = new TagBuilder("form");
|
||||||
tagBuilder.MergeAttributes(GetHtmlAttributeDictionaryOrNull(htmlAttributes));
|
tagBuilder.MergeAttributes(GetHtmlAttributeDictionaryOrNull(htmlAttributes));
|
||||||
|
|
||||||
|
|
@ -978,7 +1107,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual TagBuilder GenerateInput(
|
protected virtual TagBuilder GenerateInput(
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
InputType inputType,
|
InputType inputType,
|
||||||
ModelExplorer modelExplorer,
|
ModelExplorer modelExplorer,
|
||||||
string expression,
|
string expression,
|
||||||
|
|
@ -990,6 +1119,11 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
string format,
|
string format,
|
||||||
IDictionary<string, object> htmlAttributes)
|
IDictionary<string, object> htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (viewContext == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewContext));
|
||||||
|
}
|
||||||
|
|
||||||
// Not valid to use TextBoxForModel() and so on in a top-level view; would end up with an unnamed input
|
// Not valid to use TextBoxForModel() and so on in a top-level view; would end up with an unnamed input
|
||||||
// elements. But we support the *ForModel() methods in any lower-level template, once HtmlFieldPrefix is
|
// elements. But we support the *ForModel() methods in any lower-level template, once HtmlFieldPrefix is
|
||||||
// non-empty.
|
// non-empty.
|
||||||
|
|
@ -1104,10 +1238,15 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual TagBuilder GenerateLink(
|
protected virtual TagBuilder GenerateLink(
|
||||||
[NotNull] string linkText,
|
string linkText,
|
||||||
[NotNull] string url,
|
string url,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (linkText == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(linkText));
|
||||||
|
}
|
||||||
|
|
||||||
var tagBuilder = new TagBuilder("a");
|
var tagBuilder = new TagBuilder("a");
|
||||||
tagBuilder.InnerHtml.SetContent(linkText);
|
tagBuilder.InnerHtml.SetContent(linkText);
|
||||||
|
|
||||||
|
|
@ -1215,9 +1354,14 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IEnumerable<SelectListItem> GetSelectListItems(
|
private static IEnumerable<SelectListItem> GetSelectListItems(
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
string expression)
|
string expression)
|
||||||
{
|
{
|
||||||
|
if (viewContext == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewContext));
|
||||||
|
}
|
||||||
|
|
||||||
// Method is called only if user did not pass a select list in. They must provide select list items in the
|
// Method is called only if user did not pass a select list in. They must provide select list items in the
|
||||||
// ViewData dictionary and definitely not as the Model. (Even if the Model datatype were correct, a
|
// ViewData dictionary and definitely not as the Model. (Even if the Model datatype were correct, a
|
||||||
// <select> element generated for a collection of SelectListItems would be useless.)
|
// <select> element generated for a collection of SelectListItems would be useless.)
|
||||||
|
|
@ -1311,7 +1455,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
{
|
{
|
||||||
groupBuilder.InnerHtml.AppendLine(GenerateOption(item));
|
groupBuilder.InnerHtml.AppendLine(GenerateOption(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
listItemBuilder.AppendLine(groupBuilder);
|
listItemBuilder.AppendLine(groupBuilder);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Dynamic;
|
using System.Dynamic;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewFeatures
|
namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
{
|
{
|
||||||
|
|
@ -13,8 +11,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
{
|
{
|
||||||
private readonly Func<ViewDataDictionary> _viewDataFunc;
|
private readonly Func<ViewDataDictionary> _viewDataFunc;
|
||||||
|
|
||||||
public DynamicViewData([NotNull] Func<ViewDataDictionary> viewDataFunc)
|
public DynamicViewData(Func<ViewDataDictionary> viewDataFunc)
|
||||||
{
|
{
|
||||||
|
if (viewDataFunc == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewDataFunc));
|
||||||
|
}
|
||||||
|
|
||||||
_viewDataFunc = viewDataFunc;
|
_viewDataFunc = viewDataFunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -40,8 +43,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
return ViewData.Keys;
|
return ViewData.Keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool TryGetMember([NotNull] GetMemberBinder binder, out object result)
|
public override bool TryGetMember(GetMemberBinder binder, out object result)
|
||||||
{
|
{
|
||||||
|
if (binder == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(binder));
|
||||||
|
}
|
||||||
|
|
||||||
result = ViewData[binder.Name];
|
result = ViewData[binder.Name];
|
||||||
|
|
||||||
// ViewDataDictionary[key] will never throw a KeyNotFoundException.
|
// ViewDataDictionary[key] will never throw a KeyNotFoundException.
|
||||||
|
|
@ -49,8 +57,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool TrySetMember([NotNull] SetMemberBinder binder, object value)
|
public override bool TrySetMember(SetMemberBinder binder, object value)
|
||||||
{
|
{
|
||||||
|
if (binder == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(binder));
|
||||||
|
}
|
||||||
|
|
||||||
ViewData[binder.Name] = value;
|
ViewData[binder.Name] = value;
|
||||||
|
|
||||||
// Can always add / update a ViewDataDictionary value.
|
// Can always add / update a ViewDataDictionary value.
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewFeatures
|
namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
{
|
{
|
||||||
|
|
@ -19,8 +18,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
return string.Equals(expression, "model", StringComparison.OrdinalIgnoreCase) ? string.Empty : expression;
|
return string.Equals(expression, "model", StringComparison.OrdinalIgnoreCase) ? string.Empty : expression;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetExpressionText([NotNull] LambdaExpression expression)
|
public static string GetExpressionText(LambdaExpression expression)
|
||||||
{
|
{
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
// Split apart the expression string for property/field accessors to create its name
|
// Split apart the expression string for property/field accessors to create its name
|
||||||
var nameParts = new Stack<string>();
|
var nameParts = new Stack<string>();
|
||||||
var part = expression.Body;
|
var part = expression.Body;
|
||||||
|
|
@ -104,9 +108,19 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string GetIndexerInvocation(
|
private static string GetIndexerInvocation(
|
||||||
[NotNull] Expression expression,
|
Expression expression,
|
||||||
[NotNull] ParameterExpression[] parameters)
|
ParameterExpression[] parameters)
|
||||||
{
|
{
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parameters == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(parameters));
|
||||||
|
}
|
||||||
|
|
||||||
var converted = Expression.Convert(expression, typeof(object));
|
var converted = Expression.Convert(expression, typeof(object));
|
||||||
var fakeParameter = Expression.Parameter(typeof(object), null);
|
var fakeParameter = Expression.Parameter(typeof(object), null);
|
||||||
var lambda = Expression.Lambda<Func<object, object>>(converted, fakeParameter);
|
var lambda = Expression.Lambda<Func<object, object>>(converted, fakeParameter);
|
||||||
|
|
|
||||||
|
|
@ -6,18 +6,26 @@ using System.Globalization;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Microsoft.AspNet.Mvc.ModelBinding;
|
using Microsoft.AspNet.Mvc.ModelBinding;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewFeatures
|
namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
{
|
{
|
||||||
public static class ExpressionMetadataProvider
|
public static class ExpressionMetadataProvider
|
||||||
{
|
{
|
||||||
public static ModelExplorer FromLambdaExpression<TModel, TResult>(
|
public static ModelExplorer FromLambdaExpression<TModel, TResult>(
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
[NotNull] ViewDataDictionary<TModel> viewData,
|
ViewDataDictionary<TModel> viewData,
|
||||||
IModelMetadataProvider metadataProvider)
|
IModelMetadataProvider metadataProvider)
|
||||||
{
|
{
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (viewData == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewData));
|
||||||
|
}
|
||||||
|
|
||||||
string propertyName = null;
|
string propertyName = null;
|
||||||
Type containerType = null;
|
Type containerType = null;
|
||||||
var legalExpression = false;
|
var legalExpression = false;
|
||||||
|
|
@ -103,9 +111,14 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static ModelExplorer FromStringExpression(
|
public static ModelExplorer FromStringExpression(
|
||||||
string expression,
|
string expression,
|
||||||
[NotNull] ViewDataDictionary viewData,
|
ViewDataDictionary viewData,
|
||||||
IModelMetadataProvider metadataProvider)
|
IModelMetadataProvider metadataProvider)
|
||||||
{
|
{
|
||||||
|
if (viewData == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewData));
|
||||||
|
}
|
||||||
|
|
||||||
var viewDataInfo = ViewDataEvaluator.Eval(viewData, expression);
|
var viewDataInfo = ViewDataEvaluator.Eval(viewData, expression);
|
||||||
if (viewDataInfo == null)
|
if (viewDataInfo == null)
|
||||||
{
|
{
|
||||||
|
|
@ -160,9 +173,14 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ModelExplorer FromModel(
|
private static ModelExplorer FromModel(
|
||||||
[NotNull] ViewDataDictionary viewData,
|
ViewDataDictionary viewData,
|
||||||
IModelMetadataProvider metadataProvider)
|
IModelMetadataProvider metadataProvider)
|
||||||
{
|
{
|
||||||
|
if (viewData == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewData));
|
||||||
|
}
|
||||||
|
|
||||||
if (viewData.ModelMetadata.ModelType == typeof(object))
|
if (viewData.ModelMetadata.ModelType == typeof(object))
|
||||||
{
|
{
|
||||||
// Use common simple type rather than object so e.g. Editor() at least generates a TextBox.
|
// Use common simple type rather than object so e.g. Editor() at least generates a TextBox.
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewFeatures
|
namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
{
|
{
|
||||||
|
|
@ -30,16 +29,26 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool RenderedField([NotNull] string fieldName)
|
public bool RenderedField(string fieldName)
|
||||||
{
|
{
|
||||||
|
if (fieldName == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(fieldName));
|
||||||
|
}
|
||||||
|
|
||||||
bool result;
|
bool result;
|
||||||
_renderedFields.TryGetValue(fieldName, out result);
|
_renderedFields.TryGetValue(fieldName, out result);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RenderedField([NotNull] string fieldName, bool value)
|
public void RenderedField(string fieldName, bool value)
|
||||||
{
|
{
|
||||||
|
if (fieldName == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(fieldName));
|
||||||
|
}
|
||||||
|
|
||||||
_renderedFields[fieldName] = value;
|
_renderedFields[fieldName] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,13 +40,43 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
/// Initializes a new instance of the <see cref="HtmlHelper"/> class.
|
/// Initializes a new instance of the <see cref="HtmlHelper"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public HtmlHelper(
|
public HtmlHelper(
|
||||||
[NotNull] IHtmlGenerator htmlGenerator,
|
IHtmlGenerator htmlGenerator,
|
||||||
[NotNull] ICompositeViewEngine viewEngine,
|
ICompositeViewEngine viewEngine,
|
||||||
[NotNull] IModelMetadataProvider metadataProvider,
|
IModelMetadataProvider metadataProvider,
|
||||||
[NotNull] IHtmlEncoder htmlEncoder,
|
IHtmlEncoder htmlEncoder,
|
||||||
[NotNull] IUrlEncoder urlEncoder,
|
IUrlEncoder urlEncoder,
|
||||||
[NotNull] IJavaScriptStringEncoder javaScriptStringEncoder)
|
IJavaScriptStringEncoder javaScriptStringEncoder)
|
||||||
{
|
{
|
||||||
|
if (htmlGenerator == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlGenerator));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (viewEngine == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewEngine));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (metadataProvider == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(metadataProvider));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (htmlEncoder == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlEncoder));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (urlEncoder == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(urlEncoder));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (javaScriptStringEncoder == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(javaScriptStringEncoder));
|
||||||
|
}
|
||||||
|
|
||||||
_viewEngine = viewEngine;
|
_viewEngine = viewEngine;
|
||||||
_htmlGenerator = htmlGenerator;
|
_htmlGenerator = htmlGenerator;
|
||||||
_htmlEncoder = htmlEncoder;
|
_htmlEncoder = htmlEncoder;
|
||||||
|
|
@ -184,14 +214,19 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
return dictionary;
|
return dictionary;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Contextualize([NotNull] ViewContext viewContext)
|
public virtual void Contextualize(ViewContext viewContext)
|
||||||
{
|
{
|
||||||
|
if (viewContext == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewContext));
|
||||||
|
}
|
||||||
|
|
||||||
ViewContext = viewContext;
|
ViewContext = viewContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public IHtmlContent ActionLink(
|
public IHtmlContent ActionLink(
|
||||||
[NotNull] string linkText,
|
string linkText,
|
||||||
string actionName,
|
string actionName,
|
||||||
string controllerName,
|
string controllerName,
|
||||||
string protocol,
|
string protocol,
|
||||||
|
|
@ -200,6 +235,11 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
object routeValues,
|
object routeValues,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (linkText == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(linkText));
|
||||||
|
}
|
||||||
|
|
||||||
var tagBuilder = _htmlGenerator.GenerateActionLink(
|
var tagBuilder = _htmlGenerator.GenerateActionLink(
|
||||||
linkText,
|
linkText,
|
||||||
actionName,
|
actionName,
|
||||||
|
|
@ -277,8 +317,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public string GenerateIdFromName([NotNull] string fullName)
|
public string GenerateIdFromName(string fullName)
|
||||||
{
|
{
|
||||||
|
if (fullName == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(fullName));
|
||||||
|
}
|
||||||
|
|
||||||
return TagBuilder.CreateSanitizedId(fullName, IdAttributeDotReplacement);
|
return TagBuilder.CreateSanitizedId(fullName, IdAttributeDotReplacement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -360,8 +405,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public IEnumerable<SelectListItem> GetEnumSelectList([NotNull] Type enumType)
|
public IEnumerable<SelectListItem> GetEnumSelectList(Type enumType)
|
||||||
{
|
{
|
||||||
|
if (enumType == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(enumType));
|
||||||
|
}
|
||||||
|
|
||||||
var metadata = MetadataProvider.GetMetadataForType(enumType);
|
var metadata = MetadataProvider.GetMetadataForType(enumType);
|
||||||
if (!metadata.IsEnum || metadata.IsFlagsEnum)
|
if (!metadata.IsEnum || metadata.IsFlagsEnum)
|
||||||
{
|
{
|
||||||
|
|
@ -421,10 +471,15 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public async Task<IHtmlContent> PartialAsync(
|
public async Task<IHtmlContent> PartialAsync(
|
||||||
[NotNull] string partialViewName,
|
string partialViewName,
|
||||||
object model,
|
object model,
|
||||||
ViewDataDictionary viewData)
|
ViewDataDictionary viewData)
|
||||||
{
|
{
|
||||||
|
if (partialViewName == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(partialViewName));
|
||||||
|
}
|
||||||
|
|
||||||
using (var writer = new StringCollectionTextWriter(Encoding.UTF8))
|
using (var writer = new StringCollectionTextWriter(Encoding.UTF8))
|
||||||
{
|
{
|
||||||
await RenderPartialCoreAsync(partialViewName, model, viewData, writer);
|
await RenderPartialCoreAsync(partialViewName, model, viewData, writer);
|
||||||
|
|
@ -433,8 +488,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public Task RenderPartialAsync([NotNull] string partialViewName, object model, ViewDataDictionary viewData)
|
public Task RenderPartialAsync(string partialViewName, object model, ViewDataDictionary viewData)
|
||||||
{
|
{
|
||||||
|
if (partialViewName == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(partialViewName));
|
||||||
|
}
|
||||||
|
|
||||||
return RenderPartialCoreAsync(partialViewName, model, viewData, ViewContext.Writer);
|
return RenderPartialCoreAsync(partialViewName, model, viewData, ViewContext.Writer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -455,11 +515,16 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
return templateBuilder.Build();
|
return templateBuilder.Build();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual async Task RenderPartialCoreAsync([NotNull] string partialViewName,
|
protected virtual async Task RenderPartialCoreAsync(string partialViewName,
|
||||||
object model,
|
object model,
|
||||||
ViewDataDictionary viewData,
|
ViewDataDictionary viewData,
|
||||||
TextWriter writer)
|
TextWriter writer)
|
||||||
{
|
{
|
||||||
|
if (partialViewName == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(partialViewName));
|
||||||
|
}
|
||||||
|
|
||||||
// Determine which ViewData we should use to construct a new ViewData
|
// Determine which ViewData we should use to construct a new ViewData
|
||||||
var baseViewData = viewData ?? ViewData;
|
var baseViewData = viewData ?? ViewData;
|
||||||
|
|
||||||
|
|
@ -522,7 +587,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public IHtmlContent RouteLink(
|
public IHtmlContent RouteLink(
|
||||||
[NotNull] string linkText,
|
string linkText,
|
||||||
string routeName,
|
string routeName,
|
||||||
string protocol,
|
string protocol,
|
||||||
string hostName,
|
string hostName,
|
||||||
|
|
@ -530,6 +595,11 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
object routeValues,
|
object routeValues,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (linkText == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(linkText));
|
||||||
|
}
|
||||||
|
|
||||||
var tagBuilder = _htmlGenerator.GenerateRouteLink(
|
var tagBuilder = _htmlGenerator.GenerateRouteLink(
|
||||||
linkText,
|
linkText,
|
||||||
routeName,
|
routeName,
|
||||||
|
|
@ -647,8 +717,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
return new BufferedHtmlContent().Append(checkbox).Append(hidden);
|
return new BufferedHtmlContent().Append(checkbox).Append(hidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual string GenerateDisplayName([NotNull] ModelExplorer modelExplorer, string expression)
|
protected virtual string GenerateDisplayName(ModelExplorer modelExplorer, string expression)
|
||||||
{
|
{
|
||||||
|
if (modelExplorer == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(modelExplorer));
|
||||||
|
}
|
||||||
|
|
||||||
// We don't call ModelMetadata.GetDisplayName here because
|
// We don't call ModelMetadata.GetDisplayName here because
|
||||||
// we want to fall back to the field name rather than the ModelType.
|
// we want to fall back to the field name rather than the ModelType.
|
||||||
// This is similar to how the GenerateLabel get the text of a label.
|
// This is similar to how the GenerateLabel get the text of a label.
|
||||||
|
|
@ -852,11 +927,16 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual IHtmlContent GenerateLabel(
|
protected virtual IHtmlContent GenerateLabel(
|
||||||
[NotNull] ModelExplorer modelExplorer,
|
ModelExplorer modelExplorer,
|
||||||
string expression,
|
string expression,
|
||||||
string labelText,
|
string labelText,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (modelExplorer == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(modelExplorer));
|
||||||
|
}
|
||||||
|
|
||||||
var tagBuilder = _htmlGenerator.GenerateLabel(
|
var tagBuilder = _htmlGenerator.GenerateLabel(
|
||||||
ViewContext,
|
ViewContext,
|
||||||
modelExplorer,
|
modelExplorer,
|
||||||
|
|
@ -1071,8 +1151,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
/// Thrown if <paramref name="metadata"/>'s <see cref="ModelMetadata.ModelType"/> is not an <see cref="Enum"/>
|
/// Thrown if <paramref name="metadata"/>'s <see cref="ModelMetadata.ModelType"/> is not an <see cref="Enum"/>
|
||||||
/// or if it has a <see cref="FlagsAttribute"/>.
|
/// or if it has a <see cref="FlagsAttribute"/>.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
protected virtual IEnumerable<SelectListItem> GetEnumSelectList([NotNull] ModelMetadata metadata)
|
protected virtual IEnumerable<SelectListItem> GetEnumSelectList(ModelMetadata metadata)
|
||||||
{
|
{
|
||||||
|
if (metadata == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(metadata));
|
||||||
|
}
|
||||||
|
|
||||||
if (!metadata.IsEnum || metadata.IsFlagsEnum)
|
if (!metadata.IsEnum || metadata.IsFlagsEnum)
|
||||||
{
|
{
|
||||||
var message = Resources.FormatHtmlHelper_TypeNotSupported_ForGetEnumSelectList(
|
var message = Resources.FormatHtmlHelper_TypeNotSupported_ForGetEnumSelectList(
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ using Microsoft.AspNet.Html.Abstractions;
|
||||||
using Microsoft.AspNet.Mvc.ModelBinding;
|
using Microsoft.AspNet.Mvc.ModelBinding;
|
||||||
using Microsoft.AspNet.Mvc.Rendering;
|
using Microsoft.AspNet.Mvc.Rendering;
|
||||||
using Microsoft.AspNet.Mvc.ViewEngines;
|
using Microsoft.AspNet.Mvc.ViewEngines;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
using Microsoft.Framework.WebEncoders;
|
using Microsoft.Framework.WebEncoders;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewFeatures
|
namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
|
|
@ -19,21 +18,50 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
/// Initializes a new instance of the <see cref="HtmlHelper{TModel}"/> class.
|
/// Initializes a new instance of the <see cref="HtmlHelper{TModel}"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public HtmlHelper(
|
public HtmlHelper(
|
||||||
[NotNull] IHtmlGenerator htmlGenerator,
|
IHtmlGenerator htmlGenerator,
|
||||||
[NotNull] ICompositeViewEngine viewEngine,
|
ICompositeViewEngine viewEngine,
|
||||||
[NotNull] IModelMetadataProvider metadataProvider,
|
IModelMetadataProvider metadataProvider,
|
||||||
[NotNull] IHtmlEncoder htmlEncoder,
|
IHtmlEncoder htmlEncoder,
|
||||||
[NotNull] IUrlEncoder urlEncoder,
|
IUrlEncoder urlEncoder,
|
||||||
[NotNull] IJavaScriptStringEncoder javaScriptStringEncoder)
|
IJavaScriptStringEncoder javaScriptStringEncoder)
|
||||||
: base(htmlGenerator, viewEngine, metadataProvider, htmlEncoder, urlEncoder, javaScriptStringEncoder)
|
: base(htmlGenerator, viewEngine, metadataProvider, htmlEncoder, urlEncoder, javaScriptStringEncoder)
|
||||||
{
|
{
|
||||||
|
if (htmlGenerator == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlGenerator));
|
||||||
|
}
|
||||||
|
if (viewEngine == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewEngine));
|
||||||
|
}
|
||||||
|
if (metadataProvider == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(metadataProvider));
|
||||||
|
}
|
||||||
|
if (htmlEncoder == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlEncoder));
|
||||||
|
}
|
||||||
|
if (urlEncoder == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(urlEncoder));
|
||||||
|
}
|
||||||
|
if (javaScriptStringEncoder == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(javaScriptStringEncoder));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public new ViewDataDictionary<TModel> ViewData { get; private set; }
|
public new ViewDataDictionary<TModel> ViewData { get; private set; }
|
||||||
|
|
||||||
public override void Contextualize([NotNull] ViewContext viewContext)
|
public override void Contextualize(ViewContext viewContext)
|
||||||
{
|
{
|
||||||
|
if (viewContext == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewContext));
|
||||||
|
}
|
||||||
|
|
||||||
if (viewContext.ViewData == null)
|
if (viewContext.ViewData == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentException(Resources.FormatPropertyOfTypeCannotBeNull(
|
throw new ArgumentException(Resources.FormatPropertyOfTypeCannotBeNull(
|
||||||
|
|
@ -58,9 +86,14 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public IHtmlContent CheckBoxFor(
|
public IHtmlContent CheckBoxFor(
|
||||||
[NotNull] Expression<Func<TModel, bool>> expression,
|
Expression<Func<TModel, bool>> expression,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
var modelExplorer = GetModelExplorer(expression);
|
var modelExplorer = GetModelExplorer(expression);
|
||||||
return GenerateCheckBox(modelExplorer, GetExpressionName(expression), isChecked: null,
|
return GenerateCheckBox(modelExplorer, GetExpressionName(expression), isChecked: null,
|
||||||
htmlAttributes: htmlAttributes);
|
htmlAttributes: htmlAttributes);
|
||||||
|
|
@ -68,11 +101,16 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public IHtmlContent DropDownListFor<TResult>(
|
public IHtmlContent DropDownListFor<TResult>(
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
IEnumerable<SelectListItem> selectList,
|
IEnumerable<SelectListItem> selectList,
|
||||||
string optionLabel,
|
string optionLabel,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
var modelExplorer = ExpressionMetadataProvider.FromLambdaExpression(expression, ViewData, MetadataProvider);
|
var modelExplorer = ExpressionMetadataProvider.FromLambdaExpression(expression, ViewData, MetadataProvider);
|
||||||
|
|
||||||
return GenerateDropDown(modelExplorer, ExpressionHelper.GetExpressionText(expression), selectList,
|
return GenerateDropDown(modelExplorer, ExpressionHelper.GetExpressionText(expression), selectList,
|
||||||
|
|
@ -81,11 +119,16 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public IHtmlContent DisplayFor<TResult>(
|
public IHtmlContent DisplayFor<TResult>(
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
string templateName,
|
string templateName,
|
||||||
string htmlFieldName,
|
string htmlFieldName,
|
||||||
object additionalViewData)
|
object additionalViewData)
|
||||||
{
|
{
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
var modelExplorer = ExpressionMetadataProvider.FromLambdaExpression(expression,
|
var modelExplorer = ExpressionMetadataProvider.FromLambdaExpression(expression,
|
||||||
ViewData,
|
ViewData,
|
||||||
MetadataProvider);
|
MetadataProvider);
|
||||||
|
|
@ -97,16 +140,26 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public string DisplayNameFor<TResult>([NotNull] Expression<Func<TModel, TResult>> expression)
|
public string DisplayNameFor<TResult>(Expression<Func<TModel, TResult>> expression)
|
||||||
{
|
{
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
var modelExplorer = GetModelExplorer(expression);
|
var modelExplorer = GetModelExplorer(expression);
|
||||||
return GenerateDisplayName(modelExplorer, ExpressionHelper.GetExpressionText(expression));
|
return GenerateDisplayName(modelExplorer, ExpressionHelper.GetExpressionText(expression));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public string DisplayNameForInnerType<TModelItem, TResult>(
|
public string DisplayNameForInnerType<TModelItem, TResult>(
|
||||||
[NotNull] Expression<Func<TModelItem, TResult>> expression)
|
Expression<Func<TModelItem, TResult>> expression)
|
||||||
{
|
{
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
var modelExplorer = ExpressionMetadataProvider.FromLambdaExpression<TModelItem, TResult>(
|
var modelExplorer = ExpressionMetadataProvider.FromLambdaExpression<TModelItem, TResult>(
|
||||||
expression,
|
expression,
|
||||||
new ViewDataDictionary<TModelItem>(ViewData, model: null),
|
new ViewDataDictionary<TModelItem>(ViewData, model: null),
|
||||||
|
|
@ -122,18 +175,28 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public string DisplayTextFor<TResult>([NotNull] Expression<Func<TModel, TResult>> expression)
|
public string DisplayTextFor<TResult>(Expression<Func<TModel, TResult>> expression)
|
||||||
{
|
{
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
return GenerateDisplayText(GetModelExplorer(expression));
|
return GenerateDisplayText(GetModelExplorer(expression));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public IHtmlContent EditorFor<TResult>(
|
public IHtmlContent EditorFor<TResult>(
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
string templateName,
|
string templateName,
|
||||||
string htmlFieldName,
|
string htmlFieldName,
|
||||||
object additionalViewData)
|
object additionalViewData)
|
||||||
{
|
{
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
var modelExplorer = ExpressionMetadataProvider.FromLambdaExpression(expression, ViewData, MetadataProvider);
|
var modelExplorer = ExpressionMetadataProvider.FromLambdaExpression(expression, ViewData, MetadataProvider);
|
||||||
|
|
||||||
return GenerateEditor(
|
return GenerateEditor(
|
||||||
|
|
@ -145,9 +208,14 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public IHtmlContent HiddenFor<TResult>(
|
public IHtmlContent HiddenFor<TResult>(
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
var modelExplorer = GetModelExplorer(expression);
|
var modelExplorer = GetModelExplorer(expression);
|
||||||
return GenerateHidden(
|
return GenerateHidden(
|
||||||
modelExplorer,
|
modelExplorer,
|
||||||
|
|
@ -158,17 +226,27 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public string IdFor<TResult>([NotNull] Expression<Func<TModel, TResult>> expression)
|
public string IdFor<TResult>(Expression<Func<TModel, TResult>> expression)
|
||||||
{
|
{
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
return GenerateId(GetExpressionName(expression));
|
return GenerateId(GetExpressionName(expression));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public IHtmlContent LabelFor<TResult>(
|
public IHtmlContent LabelFor<TResult>(
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
string labelText,
|
string labelText,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
var modelExplorer = GetModelExplorer(expression);
|
var modelExplorer = GetModelExplorer(expression);
|
||||||
return GenerateLabel(
|
return GenerateLabel(
|
||||||
modelExplorer,
|
modelExplorer,
|
||||||
|
|
@ -179,10 +257,15 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public IHtmlContent ListBoxFor<TResult>(
|
public IHtmlContent ListBoxFor<TResult>(
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
IEnumerable<SelectListItem> selectList,
|
IEnumerable<SelectListItem> selectList,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
var modelExplorer = GetModelExplorer(expression);
|
var modelExplorer = GetModelExplorer(expression);
|
||||||
var name = ExpressionHelper.GetExpressionText(expression);
|
var name = ExpressionHelper.GetExpressionText(expression);
|
||||||
|
|
||||||
|
|
@ -190,17 +273,27 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public string NameFor<TResult>([NotNull] Expression<Func<TModel, TResult>> expression)
|
public string NameFor<TResult>(Expression<Func<TModel, TResult>> expression)
|
||||||
{
|
{
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
var expressionName = GetExpressionName(expression);
|
var expressionName = GetExpressionName(expression);
|
||||||
return Name(expressionName);
|
return Name(expressionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public IHtmlContent PasswordFor<TResult>(
|
public IHtmlContent PasswordFor<TResult>(
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
var modelExplorer = GetModelExplorer(expression);
|
var modelExplorer = GetModelExplorer(expression);
|
||||||
return GeneratePassword(
|
return GeneratePassword(
|
||||||
modelExplorer,
|
modelExplorer,
|
||||||
|
|
@ -211,10 +304,20 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public IHtmlContent RadioButtonFor<TResult>(
|
public IHtmlContent RadioButtonFor<TResult>(
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
[NotNull] object value,
|
object value,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(value));
|
||||||
|
}
|
||||||
|
|
||||||
var modelExplorer = GetModelExplorer(expression);
|
var modelExplorer = GetModelExplorer(expression);
|
||||||
return GenerateRadioButton(
|
return GenerateRadioButton(
|
||||||
modelExplorer,
|
modelExplorer,
|
||||||
|
|
@ -226,21 +329,31 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public IHtmlContent TextAreaFor<TResult>(
|
public IHtmlContent TextAreaFor<TResult>(
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
int rows,
|
int rows,
|
||||||
int columns,
|
int columns,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
var modelExplorer = GetModelExplorer(expression);
|
var modelExplorer = GetModelExplorer(expression);
|
||||||
return GenerateTextArea(modelExplorer, GetExpressionName(expression), rows, columns, htmlAttributes);
|
return GenerateTextArea(modelExplorer, GetExpressionName(expression), rows, columns, htmlAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public IHtmlContent TextBoxFor<TResult>(
|
public IHtmlContent TextBoxFor<TResult>(
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
string format,
|
string format,
|
||||||
object htmlAttributes)
|
object htmlAttributes)
|
||||||
{
|
{
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
var modelExplorer = GetModelExplorer(expression);
|
var modelExplorer = GetModelExplorer(expression);
|
||||||
return GenerateTextBox(
|
return GenerateTextBox(
|
||||||
modelExplorer,
|
modelExplorer,
|
||||||
|
|
@ -250,13 +363,23 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
htmlAttributes);
|
htmlAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected string GetExpressionName<TResult>([NotNull] Expression<Func<TModel, TResult>> expression)
|
protected string GetExpressionName<TResult>(Expression<Func<TModel, TResult>> expression)
|
||||||
{
|
{
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
return ExpressionHelper.GetExpressionText(expression);
|
return ExpressionHelper.GetExpressionText(expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ModelExplorer GetModelExplorer<TResult>([NotNull] Expression<Func<TModel, TResult>> expression)
|
protected ModelExplorer GetModelExplorer<TResult>(Expression<Func<TModel, TResult>> expression)
|
||||||
{
|
{
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
var modelExplorer = ExpressionMetadataProvider.FromLambdaExpression(expression, ViewData, MetadataProvider);
|
var modelExplorer = ExpressionMetadataProvider.FromLambdaExpression(expression, ViewData, MetadataProvider);
|
||||||
if (modelExplorer == null)
|
if (modelExplorer == null)
|
||||||
{
|
{
|
||||||
|
|
@ -269,11 +392,16 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public IHtmlContent ValidationMessageFor<TResult>(
|
public IHtmlContent ValidationMessageFor<TResult>(
|
||||||
[NotNull] Expression<Func<TModel, TResult>> expression,
|
Expression<Func<TModel, TResult>> expression,
|
||||||
string message,
|
string message,
|
||||||
object htmlAttributes,
|
object htmlAttributes,
|
||||||
string tag)
|
string tag)
|
||||||
{
|
{
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
return GenerateValidationMessage(ExpressionHelper.GetExpressionText(expression),
|
return GenerateValidationMessage(ExpressionHelper.GetExpressionText(expression),
|
||||||
message,
|
message,
|
||||||
htmlAttributes,
|
htmlAttributes,
|
||||||
|
|
@ -281,8 +409,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public string ValueFor<TResult>([NotNull] Expression<Func<TModel, TResult>> expression, string format)
|
public string ValueFor<TResult>(Expression<Func<TModel, TResult>> expression, string format)
|
||||||
{
|
{
|
||||||
|
if (expression == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(expression));
|
||||||
|
}
|
||||||
|
|
||||||
var modelExplorer = GetModelExplorer(expression);
|
var modelExplorer = GetModelExplorer(expression);
|
||||||
return GenerateValue(
|
return GenerateValue(
|
||||||
ExpressionHelper.GetExpressionText(expression),
|
ExpressionHelper.GetExpressionText(expression),
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ using Microsoft.AspNet.Html.Abstractions;
|
||||||
using Microsoft.AspNet.Mvc.ModelBinding;
|
using Microsoft.AspNet.Mvc.ModelBinding;
|
||||||
using Microsoft.AspNet.Mvc.ModelBinding.Validation;
|
using Microsoft.AspNet.Mvc.ModelBinding.Validation;
|
||||||
using Microsoft.AspNet.Mvc.Rendering;
|
using Microsoft.AspNet.Mvc.Rendering;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewFeatures
|
namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
{
|
{
|
||||||
|
|
@ -24,7 +23,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
string FormatValue(object value, string format);
|
string FormatValue(object value, string format);
|
||||||
|
|
||||||
TagBuilder GenerateActionLink(
|
TagBuilder GenerateActionLink(
|
||||||
[NotNull] string linkText,
|
string linkText,
|
||||||
string actionName,
|
string actionName,
|
||||||
string controllerName,
|
string controllerName,
|
||||||
string protocol,
|
string protocol,
|
||||||
|
|
@ -38,7 +37,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="viewContext">The <see cref="ViewContext"/> instance for the current scope.</param>
|
/// <param name="viewContext">The <see cref="ViewContext"/> instance for the current scope.</param>
|
||||||
/// <returns>An <see cref="IHtmlContent"/> instance for the <input type="hidden".../> element.</returns>
|
/// <returns>An <see cref="IHtmlContent"/> instance for the <input type="hidden".../> element.</returns>
|
||||||
IHtmlContent GenerateAntiforgery([NotNull] ViewContext viewContext);
|
IHtmlContent GenerateAntiforgery(ViewContext viewContext);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generate a <input type="checkbox".../> element.
|
/// Generate a <input type="checkbox".../> element.
|
||||||
|
|
@ -55,7 +54,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
/// A <see cref="TagBuilder"/> instance for the <input type="checkbox".../> element.
|
/// A <see cref="TagBuilder"/> instance for the <input type="checkbox".../> element.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
TagBuilder GenerateCheckBox(
|
TagBuilder GenerateCheckBox(
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
ModelExplorer modelExplorer,
|
ModelExplorer modelExplorer,
|
||||||
string expression,
|
string expression,
|
||||||
bool? isChecked,
|
bool? isChecked,
|
||||||
|
|
@ -67,7 +66,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
/// checkbox was present on the page when the request was submitted.
|
/// checkbox was present on the page when the request was submitted.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
TagBuilder GenerateHiddenForCheckbox(
|
TagBuilder GenerateHiddenForCheckbox(
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
ModelExplorer modelExplorer,
|
ModelExplorer modelExplorer,
|
||||||
string expression);
|
string expression);
|
||||||
|
|
||||||
|
|
@ -93,7 +92,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
/// A <see cref="TagBuilder"/> instance for the </form> element.
|
/// A <see cref="TagBuilder"/> instance for the </form> element.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
TagBuilder GenerateForm(
|
TagBuilder GenerateForm(
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
string actionName,
|
string actionName,
|
||||||
string controllerName,
|
string controllerName,
|
||||||
object routeValues,
|
object routeValues,
|
||||||
|
|
@ -121,14 +120,14 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
/// A <see cref="TagBuilder"/> instance for the </form> element.
|
/// A <see cref="TagBuilder"/> instance for the </form> element.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
TagBuilder GenerateRouteForm(
|
TagBuilder GenerateRouteForm(
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
string routeName,
|
string routeName,
|
||||||
object routeValues,
|
object routeValues,
|
||||||
string method,
|
string method,
|
||||||
object htmlAttributes);
|
object htmlAttributes);
|
||||||
|
|
||||||
TagBuilder GenerateHidden(
|
TagBuilder GenerateHidden(
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
ModelExplorer modelExplorer,
|
ModelExplorer modelExplorer,
|
||||||
string expression,
|
string expression,
|
||||||
object value,
|
object value,
|
||||||
|
|
@ -136,21 +135,21 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
object htmlAttributes);
|
object htmlAttributes);
|
||||||
|
|
||||||
TagBuilder GenerateLabel(
|
TagBuilder GenerateLabel(
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
[NotNull] ModelExplorer modelExplorer,
|
ModelExplorer modelExplorer,
|
||||||
string expression,
|
string expression,
|
||||||
string labelText,
|
string labelText,
|
||||||
object htmlAttributes);
|
object htmlAttributes);
|
||||||
|
|
||||||
TagBuilder GeneratePassword(
|
TagBuilder GeneratePassword(
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
ModelExplorer modelExplorer,
|
ModelExplorer modelExplorer,
|
||||||
string expression,
|
string expression,
|
||||||
object value,
|
object value,
|
||||||
object htmlAttributes);
|
object htmlAttributes);
|
||||||
|
|
||||||
TagBuilder GenerateRadioButton(
|
TagBuilder GenerateRadioButton(
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
ModelExplorer modelExplorer,
|
ModelExplorer modelExplorer,
|
||||||
string expression,
|
string expression,
|
||||||
object value,
|
object value,
|
||||||
|
|
@ -158,7 +157,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
object htmlAttributes);
|
object htmlAttributes);
|
||||||
|
|
||||||
TagBuilder GenerateRouteLink(
|
TagBuilder GenerateRouteLink(
|
||||||
[NotNull] string linkText,
|
string linkText,
|
||||||
string routeName,
|
string routeName,
|
||||||
string protocol,
|
string protocol,
|
||||||
string hostName,
|
string hostName,
|
||||||
|
|
@ -201,7 +200,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
TagBuilder GenerateSelect(
|
TagBuilder GenerateSelect(
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
ModelExplorer modelExplorer,
|
ModelExplorer modelExplorer,
|
||||||
string optionLabel,
|
string optionLabel,
|
||||||
string expression,
|
string expression,
|
||||||
|
|
@ -250,7 +249,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
TagBuilder GenerateSelect(
|
TagBuilder GenerateSelect(
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
ModelExplorer modelExplorer,
|
ModelExplorer modelExplorer,
|
||||||
string optionLabel,
|
string optionLabel,
|
||||||
string expression,
|
string expression,
|
||||||
|
|
@ -260,7 +259,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
object htmlAttributes);
|
object htmlAttributes);
|
||||||
|
|
||||||
TagBuilder GenerateTextArea(
|
TagBuilder GenerateTextArea(
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
ModelExplorer modelExplorer,
|
ModelExplorer modelExplorer,
|
||||||
string expression,
|
string expression,
|
||||||
int rows,
|
int rows,
|
||||||
|
|
@ -268,7 +267,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
object htmlAttributes);
|
object htmlAttributes);
|
||||||
|
|
||||||
TagBuilder GenerateTextBox(
|
TagBuilder GenerateTextBox(
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
ModelExplorer modelExplorer,
|
ModelExplorer modelExplorer,
|
||||||
string expression,
|
string expression,
|
||||||
object value,
|
object value,
|
||||||
|
|
@ -276,14 +275,14 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
object htmlAttributes);
|
object htmlAttributes);
|
||||||
|
|
||||||
TagBuilder GenerateValidationMessage(
|
TagBuilder GenerateValidationMessage(
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
string expression,
|
string expression,
|
||||||
string message,
|
string message,
|
||||||
string tag,
|
string tag,
|
||||||
object htmlAttributes);
|
object htmlAttributes);
|
||||||
|
|
||||||
TagBuilder GenerateValidationSummary(
|
TagBuilder GenerateValidationSummary(
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
bool excludePropertyErrors,
|
bool excludePropertyErrors,
|
||||||
string message,
|
string message,
|
||||||
string headerTag,
|
string headerTag,
|
||||||
|
|
@ -294,7 +293,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
/// implementations.
|
/// implementations.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
IEnumerable<ModelClientValidationRule> GetClientValidationRules(
|
IEnumerable<ModelClientValidationRule> GetClientValidationRules(
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
ModelExplorer modelExplorer,
|
ModelExplorer modelExplorer,
|
||||||
string expression);
|
string expression);
|
||||||
|
|
||||||
|
|
@ -333,7 +332,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
/// See <see cref="GenerateSelect"/> for information about how the return value may be used.
|
/// See <see cref="GenerateSelect"/> for information about how the return value may be used.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
IReadOnlyCollection<string> GetCurrentValues(
|
IReadOnlyCollection<string> GetCurrentValues(
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
ModelExplorer modelExplorer,
|
ModelExplorer modelExplorer,
|
||||||
string expression,
|
string expression,
|
||||||
bool allowMultiple);
|
bool allowMultiple);
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.AspNet.Http;
|
using Microsoft.AspNet.Http;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewFeatures
|
namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
{
|
{
|
||||||
|
|
@ -17,13 +16,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="context">The <see cref="HttpContext"/>.</param>
|
/// <param name="context">The <see cref="HttpContext"/>.</param>
|
||||||
/// <returns>The temporary data.</returns>
|
/// <returns>The temporary data.</returns>
|
||||||
IDictionary<string, object> LoadTempData([NotNull] HttpContext context);
|
IDictionary<string, object> LoadTempData(HttpContext context);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Saves the temporary data.
|
/// Saves the temporary data.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="context">The <see cref="HttpContext"/>.</param>
|
/// <param name="context">The <see cref="HttpContext"/>.</param>
|
||||||
/// <param name="values">The values to save.</param>
|
/// <param name="values">The values to save.</param>
|
||||||
void SaveTempData([NotNull] HttpContext context, IDictionary<string, object> values);
|
void SaveTempData(HttpContext context, IDictionary<string, object> values);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
using Microsoft.AspNet.Mvc.Formatters;
|
using Microsoft.AspNet.Mvc.Formatters;
|
||||||
using Microsoft.AspNet.Mvc.Rendering;
|
using Microsoft.AspNet.Mvc.Rendering;
|
||||||
|
|
||||||
|
|
@ -21,8 +21,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
/// Initializes a new instance of <see cref="JsonHelper"/> that is backed by <paramref name="jsonOutputFormatter"/>.
|
/// Initializes a new instance of <see cref="JsonHelper"/> that is backed by <paramref name="jsonOutputFormatter"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="jsonOutputFormatter">The <see cref="JsonOutputFormatter"/> used to serialize JSON.</param>
|
/// <param name="jsonOutputFormatter">The <see cref="JsonOutputFormatter"/> used to serialize JSON.</param>
|
||||||
public JsonHelper([NotNull] JsonOutputFormatter jsonOutputFormatter)
|
public JsonHelper(JsonOutputFormatter jsonOutputFormatter)
|
||||||
{
|
{
|
||||||
|
if (jsonOutputFormatter == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(jsonOutputFormatter));
|
||||||
|
}
|
||||||
|
|
||||||
_jsonOutputFormatter = jsonOutputFormatter;
|
_jsonOutputFormatter = jsonOutputFormatter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -33,8 +38,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public HtmlString Serialize(object value, [NotNull] JsonSerializerSettings serializerSettings)
|
public HtmlString Serialize(object value, JsonSerializerSettings serializerSettings)
|
||||||
{
|
{
|
||||||
|
if (serializerSettings == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(serializerSettings));
|
||||||
|
}
|
||||||
|
|
||||||
var jsonOutputFormatter = new JsonOutputFormatter(serializerSettings);
|
var jsonOutputFormatter = new JsonOutputFormatter(serializerSettings);
|
||||||
|
|
||||||
return SerializeInternal(jsonOutputFormatter, value);
|
return SerializeInternal(jsonOutputFormatter, value);
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
using Microsoft.AspNet.Mvc.ModelBinding;
|
using Microsoft.AspNet.Mvc.ModelBinding;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.Rendering
|
namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
{
|
{
|
||||||
|
|
@ -20,8 +20,18 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
/// <param name="modelExplorer">
|
/// <param name="modelExplorer">
|
||||||
/// Includes the model and metadata about the <see cref="System.Linq.Expressions.Expression"/> of interest.
|
/// Includes the model and metadata about the <see cref="System.Linq.Expressions.Expression"/> of interest.
|
||||||
/// </param>
|
/// </param>
|
||||||
public ModelExpression([NotNull] string name, [NotNull] ModelExplorer modelExplorer)
|
public ModelExpression(string name, ModelExplorer modelExplorer)
|
||||||
{
|
{
|
||||||
|
if (name == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (modelExplorer == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(modelExplorer));
|
||||||
|
}
|
||||||
|
|
||||||
Name = name;
|
Name = name;
|
||||||
ModelExplorer = modelExplorer;
|
ModelExplorer = modelExplorer;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,8 +52,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
};
|
};
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public virtual IDictionary<string, object> LoadTempData([NotNull] HttpContext context)
|
public virtual IDictionary<string, object> LoadTempData(HttpContext context)
|
||||||
{
|
{
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(context));
|
||||||
|
}
|
||||||
|
|
||||||
if (!IsSessionEnabled(context))
|
if (!IsSessionEnabled(context))
|
||||||
{
|
{
|
||||||
// Session middleware is not enabled. No-op
|
// Session middleware is not enabled. No-op
|
||||||
|
|
@ -150,8 +155,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public virtual void SaveTempData([NotNull] HttpContext context, IDictionary<string, object> values)
|
public virtual void SaveTempData(HttpContext context, IDictionary<string, object> values)
|
||||||
{
|
{
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(context));
|
||||||
|
}
|
||||||
|
|
||||||
var hasValues = (values != null && values.Count > 0);
|
var hasValues = (values != null && values.Count > 0);
|
||||||
if (hasValues)
|
if (hasValues)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Html.Abstractions;
|
using Microsoft.AspNet.Html.Abstractions;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
using Microsoft.Framework.WebEncoders;
|
using Microsoft.Framework.WebEncoders;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewFeatures
|
namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
|
|
@ -61,8 +60,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void Write([NotNull] char[] buffer, int index, int count)
|
public override void Write(char[] buffer, int index, int count)
|
||||||
{
|
{
|
||||||
|
if (buffer == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(buffer));
|
||||||
|
}
|
||||||
|
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentOutOfRangeException(nameof(index));
|
throw new ArgumentOutOfRangeException(nameof(index));
|
||||||
|
|
@ -112,8 +116,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override Task WriteAsync([NotNull] char[] buffer, int index, int count)
|
public override Task WriteAsync(char[] buffer, int index, int count)
|
||||||
{
|
{
|
||||||
|
if (buffer == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(buffer));
|
||||||
|
}
|
||||||
|
|
||||||
Write(buffer, index, count);
|
Write(buffer, index, count);
|
||||||
return _completedTask;
|
return _completedTask;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Microsoft.AspNet.Html.Abstractions;
|
using Microsoft.AspNet.Html.Abstractions;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
using Microsoft.Framework.WebEncoders;
|
using Microsoft.Framework.WebEncoders;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewFeatures
|
namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
|
|
@ -27,8 +27,18 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public void WriteTo([NotNull] TextWriter writer, [NotNull] IHtmlEncoder encoder)
|
public void WriteTo(TextWriter writer, IHtmlEncoder encoder)
|
||||||
{
|
{
|
||||||
|
if (writer == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(writer));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (encoder == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(encoder));
|
||||||
|
}
|
||||||
|
|
||||||
encoder.HtmlEncode(_input, writer);
|
encoder.HtmlEncode(_input, writer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.AspNet.Http;
|
using Microsoft.AspNet.Http;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewFeatures
|
namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
{
|
{
|
||||||
|
|
@ -24,8 +23,18 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="context">The <see cref="IHttpContextAccessor"/> that provides the HttpContext.</param>
|
/// <param name="context">The <see cref="IHttpContextAccessor"/> that provides the HttpContext.</param>
|
||||||
/// <param name="provider">The <see cref="ITempDataProvider"/> used to Load and Save data.</param>
|
/// <param name="provider">The <see cref="ITempDataProvider"/> used to Load and Save data.</param>
|
||||||
public TempDataDictionary([NotNull] IHttpContextAccessor context, [NotNull] ITempDataProvider provider)
|
public TempDataDictionary(IHttpContextAccessor context, ITempDataProvider provider)
|
||||||
{
|
{
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(context));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (provider == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(provider));
|
||||||
|
}
|
||||||
|
|
||||||
_provider = provider;
|
_provider = provider;
|
||||||
_loaded = false;
|
_loaded = false;
|
||||||
_contextAccessor = context;
|
_contextAccessor = context;
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using Microsoft.AspNet.Html.Abstractions;
|
using Microsoft.AspNet.Html.Abstractions;
|
||||||
using Microsoft.AspNet.Mvc.ModelBinding;
|
using Microsoft.AspNet.Mvc.ModelBinding;
|
||||||
using Microsoft.AspNet.Mvc.Rendering;
|
using Microsoft.AspNet.Mvc.Rendering;
|
||||||
using Microsoft.AspNet.Mvc.ViewEngines;
|
using Microsoft.AspNet.Mvc.ViewEngines;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewFeatures.Internal
|
namespace Microsoft.AspNet.Mvc.ViewFeatures.Internal
|
||||||
{
|
{
|
||||||
|
|
@ -24,15 +24,35 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures.Internal
|
||||||
private object _additionalViewData;
|
private object _additionalViewData;
|
||||||
|
|
||||||
public TemplateBuilder(
|
public TemplateBuilder(
|
||||||
[NotNull] IViewEngine viewEngine,
|
IViewEngine viewEngine,
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
[NotNull] ViewDataDictionary viewData,
|
ViewDataDictionary viewData,
|
||||||
[NotNull] ModelExplorer modelExplorer,
|
ModelExplorer modelExplorer,
|
||||||
string htmlFieldName,
|
string htmlFieldName,
|
||||||
string templateName,
|
string templateName,
|
||||||
bool readOnly,
|
bool readOnly,
|
||||||
object additionalViewData)
|
object additionalViewData)
|
||||||
{
|
{
|
||||||
|
if (viewEngine == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewEngine));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (viewContext == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewContext));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (viewData == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewData));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (modelExplorer == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(modelExplorer));
|
||||||
|
}
|
||||||
|
|
||||||
_viewEngine = viewEngine;
|
_viewEngine = viewEngine;
|
||||||
_viewContext = viewContext;
|
_viewContext = viewContext;
|
||||||
_viewData = viewData;
|
_viewData = viewData;
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ using Microsoft.AspNet.Mvc.ModelBinding;
|
||||||
using Microsoft.AspNet.Mvc.Rendering;
|
using Microsoft.AspNet.Mvc.Rendering;
|
||||||
using Microsoft.AspNet.Mvc.ViewEngines;
|
using Microsoft.AspNet.Mvc.ViewEngines;
|
||||||
using Microsoft.Framework.DependencyInjection;
|
using Microsoft.Framework.DependencyInjection;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewFeatures.Internal
|
namespace Microsoft.AspNet.Mvc.ViewFeatures.Internal
|
||||||
{
|
{
|
||||||
|
|
@ -75,12 +74,27 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures.Internal
|
||||||
private bool _readOnly;
|
private bool _readOnly;
|
||||||
|
|
||||||
public TemplateRenderer(
|
public TemplateRenderer(
|
||||||
[NotNull] IViewEngine viewEngine,
|
IViewEngine viewEngine,
|
||||||
[NotNull] ViewContext viewContext,
|
ViewContext viewContext,
|
||||||
[NotNull] ViewDataDictionary viewData,
|
ViewDataDictionary viewData,
|
||||||
string templateName,
|
string templateName,
|
||||||
bool readOnly)
|
bool readOnly)
|
||||||
{
|
{
|
||||||
|
if (viewEngine == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewEngine));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (viewContext == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewContext));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (viewData == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewData));
|
||||||
|
}
|
||||||
|
|
||||||
_viewEngine = viewEngine;
|
_viewEngine = viewEngine;
|
||||||
_viewContext = viewContext;
|
_viewContext = viewContext;
|
||||||
_viewData = viewData;
|
_viewData = viewData;
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
private static readonly MethodInfo _strongTryGetValueImplInfo =
|
private static readonly MethodInfo _strongTryGetValueImplInfo =
|
||||||
typeof(TryGetValueProvider).GetTypeInfo().GetDeclaredMethod("StrongTryGetValueImpl");
|
typeof(TryGetValueProvider).GetTypeInfo().GetDeclaredMethod("StrongTryGetValueImpl");
|
||||||
|
|
||||||
public static TryGetValueDelegate CreateInstance([NotNull] Type targetType)
|
public static TryGetValueDelegate CreateInstance(Type targetType)
|
||||||
{
|
{
|
||||||
|
if (targetType == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(targetType));
|
||||||
|
}
|
||||||
|
|
||||||
TryGetValueDelegate result;
|
TryGetValueDelegate result;
|
||||||
|
|
||||||
// Cache delegates since properties of model types are re-evaluated numerous times.
|
// Cache delegates since properties of model types are re-evaluated numerous times.
|
||||||
|
|
|
||||||
|
|
@ -5,16 +5,19 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.AspNet.Mvc.ModelBinding.Validation;
|
using Microsoft.AspNet.Mvc.ModelBinding.Validation;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewFeatures
|
namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
{
|
{
|
||||||
public static class UnobtrusiveValidationAttributesGenerator
|
public static class UnobtrusiveValidationAttributesGenerator
|
||||||
{
|
{
|
||||||
public static IDictionary<string, object> GetValidationAttributes(
|
public static IDictionary<string, object> GetValidationAttributes(
|
||||||
[NotNull] IEnumerable<ModelClientValidationRule> clientRules)
|
IEnumerable<ModelClientValidationRule> clientRules)
|
||||||
{
|
{
|
||||||
|
if (clientRules == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(clientRules));
|
||||||
|
}
|
||||||
|
|
||||||
IDictionary<string, object> results = null;
|
IDictionary<string, object> results = null;
|
||||||
|
|
||||||
foreach (var rule in clientRules)
|
foreach (var rule in clientRules)
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Antiforgery;
|
using Microsoft.AspNet.Antiforgery;
|
||||||
using Microsoft.AspNet.Mvc.Filters;
|
using Microsoft.AspNet.Mvc.Filters;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewFeatures
|
namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
{
|
{
|
||||||
|
|
@ -12,13 +12,23 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
{
|
{
|
||||||
private readonly IAntiforgery _antiforgery;
|
private readonly IAntiforgery _antiforgery;
|
||||||
|
|
||||||
public ValidateAntiforgeryTokenAuthorizationFilter([NotNull] IAntiforgery antiforgery)
|
public ValidateAntiforgeryTokenAuthorizationFilter(IAntiforgery antiforgery)
|
||||||
{
|
{
|
||||||
|
if (antiforgery == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(antiforgery));
|
||||||
|
}
|
||||||
|
|
||||||
_antiforgery = antiforgery;
|
_antiforgery = antiforgery;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task OnAuthorizationAsync([NotNull] AuthorizationContext context)
|
public Task OnAuthorizationAsync(AuthorizationContext context)
|
||||||
{
|
{
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(context));
|
||||||
|
}
|
||||||
|
|
||||||
return _antiforgery.ValidateRequestAsync(context.HttpContext);
|
return _antiforgery.ValidateRequestAsync(context.HttpContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,10 +29,18 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
/// <param name="modelState"><see cref="ModelStateDictionary"/> instance for this scope.</param>
|
/// <param name="modelState"><see cref="ModelStateDictionary"/> instance for this scope.</param>
|
||||||
/// <remarks>For use when creating a <see cref="ViewDataDictionary"/> for a new top-level scope.</remarks>
|
/// <remarks>For use when creating a <see cref="ViewDataDictionary"/> for a new top-level scope.</remarks>
|
||||||
public ViewDataDictionary(
|
public ViewDataDictionary(
|
||||||
[NotNull] IModelMetadataProvider metadataProvider,
|
IModelMetadataProvider metadataProvider,
|
||||||
[NotNull] ModelStateDictionary modelState)
|
ModelStateDictionary modelState)
|
||||||
: this(metadataProvider, modelState, declaredModelType: typeof(object))
|
: this(metadataProvider, modelState, declaredModelType: typeof(object))
|
||||||
{
|
{
|
||||||
|
if (metadataProvider == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(metadataProvider));
|
||||||
|
}
|
||||||
|
if (modelState == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(modelState));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -45,9 +53,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
/// <see cref="Type"/> will not change e.g. when copying from a <see cref="ViewDataDictionary{TModel}"/>
|
/// <see cref="Type"/> will not change e.g. when copying from a <see cref="ViewDataDictionary{TModel}"/>
|
||||||
/// instance to a base <see cref="ViewDataDictionary"/> instance.
|
/// instance to a base <see cref="ViewDataDictionary"/> instance.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public ViewDataDictionary([NotNull] ViewDataDictionary source)
|
public ViewDataDictionary(ViewDataDictionary source)
|
||||||
: this(source, source.Model, source._declaredModelType)
|
: this(source, source.Model, source._declaredModelType)
|
||||||
{
|
{
|
||||||
|
if (source == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(source));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -62,9 +74,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
/// <see cref="Model"/> is known. In this case, <see cref="object"/> is the best possible guess about the
|
/// <see cref="Model"/> is known. In this case, <see cref="object"/> is the best possible guess about the
|
||||||
/// declared type when <paramref name="model"/> is <c>null</c>.
|
/// declared type when <paramref name="model"/> is <c>null</c>.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public ViewDataDictionary([NotNull] ViewDataDictionary source, object model)
|
public ViewDataDictionary(ViewDataDictionary source, object model)
|
||||||
: this(source, model, declaredModelType: typeof(object))
|
: this(source, model, declaredModelType: typeof(object))
|
||||||
{
|
{
|
||||||
|
if (source == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(source));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -75,9 +91,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
/// <see cref="ViewDataDictionary.ModelMetadata"/> values.
|
/// <see cref="ViewDataDictionary.ModelMetadata"/> values.
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <remarks>Internal for testing.</remarks>
|
/// <remarks>Internal for testing.</remarks>
|
||||||
internal ViewDataDictionary([NotNull] IModelMetadataProvider metadataProvider)
|
internal ViewDataDictionary(IModelMetadataProvider metadataProvider)
|
||||||
: this(metadataProvider, new ModelStateDictionary())
|
: this(metadataProvider, new ModelStateDictionary())
|
||||||
{
|
{
|
||||||
|
if (metadataProvider == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(metadataProvider));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -95,10 +115,18 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
/// For use when creating a derived <see cref="ViewDataDictionary"/> for a new top-level scope.
|
/// For use when creating a derived <see cref="ViewDataDictionary"/> for a new top-level scope.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
protected ViewDataDictionary(
|
protected ViewDataDictionary(
|
||||||
[NotNull] IModelMetadataProvider metadataProvider,
|
IModelMetadataProvider metadataProvider,
|
||||||
[NotNull] Type declaredModelType)
|
Type declaredModelType)
|
||||||
: this(metadataProvider, new ModelStateDictionary(), declaredModelType)
|
: this(metadataProvider, new ModelStateDictionary(), declaredModelType)
|
||||||
{
|
{
|
||||||
|
if (metadataProvider == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(metadataProvider));
|
||||||
|
}
|
||||||
|
if (declaredModelType == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(declaredModelType));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -117,15 +145,30 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
/// For use when creating a derived <see cref="ViewDataDictionary"/> for a new top-level scope.
|
/// For use when creating a derived <see cref="ViewDataDictionary"/> for a new top-level scope.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
protected ViewDataDictionary(
|
protected ViewDataDictionary(
|
||||||
[NotNull] IModelMetadataProvider metadataProvider,
|
IModelMetadataProvider metadataProvider,
|
||||||
[NotNull] ModelStateDictionary modelState,
|
ModelStateDictionary modelState,
|
||||||
[NotNull] Type declaredModelType)
|
Type declaredModelType)
|
||||||
: this(metadataProvider,
|
: this(metadataProvider,
|
||||||
modelState,
|
modelState,
|
||||||
declaredModelType,
|
declaredModelType,
|
||||||
data: new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase),
|
data: new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase),
|
||||||
templateInfo: new TemplateInfo())
|
templateInfo: new TemplateInfo())
|
||||||
{
|
{
|
||||||
|
if (metadataProvider == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(metadataProvider));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (modelState == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(modelState));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (declaredModelType == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(declaredModelType));
|
||||||
|
}
|
||||||
|
|
||||||
// This is the core constructor called when Model is unknown. Base ModelMetadata on the declared type.
|
// This is the core constructor called when Model is unknown. Base ModelMetadata on the declared type.
|
||||||
ModelExplorer = _metadataProvider.GetModelExplorerForType(declaredModelType, model: null);
|
ModelExplorer = _metadataProvider.GetModelExplorerForType(declaredModelType, model: null);
|
||||||
}
|
}
|
||||||
|
|
@ -152,9 +195,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
/// <see cref="ViewDataDictionary(ViewDataDictionary, object, Type)"/> to ignore <c>source.Model</c>.
|
/// <see cref="ViewDataDictionary(ViewDataDictionary, object, Type)"/> to ignore <c>source.Model</c>.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
protected ViewDataDictionary([NotNull] ViewDataDictionary source, Type declaredModelType)
|
protected ViewDataDictionary(ViewDataDictionary source, Type declaredModelType)
|
||||||
: this(source, model: source.Model, declaredModelType: declaredModelType)
|
: this(source, model: source.Model, declaredModelType: declaredModelType)
|
||||||
{
|
{
|
||||||
|
if (source == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(source));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -178,13 +225,18 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
/// <paramref name="declaredModelType"/>.
|
/// <paramref name="declaredModelType"/>.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
protected ViewDataDictionary([NotNull] ViewDataDictionary source, object model, Type declaredModelType)
|
protected ViewDataDictionary(ViewDataDictionary source, object model, Type declaredModelType)
|
||||||
: this(source._metadataProvider,
|
: this(source._metadataProvider,
|
||||||
new ModelStateDictionary(source.ModelState),
|
new ModelStateDictionary(source.ModelState),
|
||||||
declaredModelType,
|
declaredModelType,
|
||||||
data: new CopyOnWriteDictionary<string, object>(source, StringComparer.OrdinalIgnoreCase),
|
data: new CopyOnWriteDictionary<string, object>(source, StringComparer.OrdinalIgnoreCase),
|
||||||
templateInfo: new TemplateInfo(source.TemplateInfo))
|
templateInfo: new TemplateInfo(source.TemplateInfo))
|
||||||
{
|
{
|
||||||
|
if (source == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(source));
|
||||||
|
}
|
||||||
|
|
||||||
// This is the core constructor called when Model is known.
|
// This is the core constructor called when Model is known.
|
||||||
var modelType = GetModelType(model);
|
var modelType = GetModelType(model);
|
||||||
var metadataModelType = source.ModelMetadata.UnderlyingOrModelType;
|
var metadataModelType = source.ModelMetadata.UnderlyingOrModelType;
|
||||||
|
|
@ -260,7 +312,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
|
|
||||||
public TemplateInfo TemplateInfo { get; }
|
public TemplateInfo TemplateInfo { get; }
|
||||||
|
|
||||||
#region IDictionary properties
|
#region IDictionary properties
|
||||||
// Do not just pass through to _data: Indexer should not throw a KeyNotFoundException.
|
// Do not just pass through to _data: Indexer should not throw a KeyNotFoundException.
|
||||||
public object this[string index]
|
public object this[string index]
|
||||||
{
|
{
|
||||||
|
|
@ -295,7 +347,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
{
|
{
|
||||||
get { return _data.Values; }
|
get { return _data.Values; }
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
// for unit testing
|
// for unit testing
|
||||||
internal IDictionary<string, object> Data
|
internal IDictionary<string, object> Data
|
||||||
|
|
@ -448,28 +500,48 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#region IDictionary methods
|
#region IDictionary methods
|
||||||
public void Add([NotNull] string key, object value)
|
public void Add(string key, object value)
|
||||||
{
|
{
|
||||||
|
if (key == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(key));
|
||||||
|
}
|
||||||
|
|
||||||
_data.Add(key, value);
|
_data.Add(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ContainsKey([NotNull] string key)
|
public bool ContainsKey(string key)
|
||||||
{
|
{
|
||||||
|
if (key == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(key));
|
||||||
|
}
|
||||||
|
|
||||||
return _data.ContainsKey(key);
|
return _data.ContainsKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Remove([NotNull] string key)
|
public bool Remove(string key)
|
||||||
{
|
{
|
||||||
|
if (key == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(key));
|
||||||
|
}
|
||||||
|
|
||||||
return _data.Remove(key);
|
return _data.Remove(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TryGetValue([NotNull] string key, out object value)
|
public bool TryGetValue(string key, out object value)
|
||||||
{
|
{
|
||||||
|
if (key == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(key));
|
||||||
|
}
|
||||||
|
|
||||||
return _data.TryGetValue(key, out value);
|
return _data.TryGetValue(key, out value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Add([NotNull] KeyValuePair<string, object> item)
|
public void Add(KeyValuePair<string, object> item)
|
||||||
{
|
{
|
||||||
_data.Add(item);
|
_data.Add(item);
|
||||||
}
|
}
|
||||||
|
|
@ -479,17 +551,22 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
_data.Clear();
|
_data.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Contains([NotNull] KeyValuePair<string, object> item)
|
public bool Contains(KeyValuePair<string, object> item)
|
||||||
{
|
{
|
||||||
return _data.Contains(item);
|
return _data.Contains(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CopyTo([NotNull] KeyValuePair<string, object>[] array, int arrayIndex)
|
public void CopyTo(KeyValuePair<string, object>[] array, int arrayIndex)
|
||||||
{
|
{
|
||||||
|
if (array == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(array));
|
||||||
|
}
|
||||||
|
|
||||||
_data.CopyTo(array, arrayIndex);
|
_data.CopyTo(array, arrayIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Remove([NotNull] KeyValuePair<string, object> item)
|
public bool Remove(KeyValuePair<string, object> item)
|
||||||
{
|
{
|
||||||
return _data.Remove(item);
|
return _data.Remove(item);
|
||||||
}
|
}
|
||||||
|
|
@ -503,6 +580,6 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
{
|
{
|
||||||
return _data.GetEnumerator();
|
return _data.GetEnumerator();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
using Microsoft.AspNet.Mvc.ModelBinding;
|
using Microsoft.AspNet.Mvc.ModelBinding;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewFeatures
|
namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
{
|
{
|
||||||
|
|
@ -17,10 +17,18 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
// References may not show up due to ActivatorUtilities use in RazorPageActivator.
|
// References may not show up due to ActivatorUtilities use in RazorPageActivator.
|
||||||
public ViewDataDictionary(
|
public ViewDataDictionary(
|
||||||
[NotNull] IModelMetadataProvider metadataProvider,
|
IModelMetadataProvider metadataProvider,
|
||||||
[NotNull] ModelStateDictionary modelState)
|
ModelStateDictionary modelState)
|
||||||
: base(metadataProvider, modelState, declaredModelType: typeof(TModel))
|
: base(metadataProvider, modelState, declaredModelType: typeof(TModel))
|
||||||
{
|
{
|
||||||
|
if (metadataProvider == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(metadataProvider));
|
||||||
|
}
|
||||||
|
if (modelState == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(modelState));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -41,9 +49,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
// References may not show up due to ActivatorUtilities use in RazorPageActivator.
|
// References may not show up due to ActivatorUtilities use in RazorPageActivator.
|
||||||
public ViewDataDictionary([NotNull] ViewDataDictionary source)
|
public ViewDataDictionary(ViewDataDictionary source)
|
||||||
: base(source, declaredModelType: typeof(TModel))
|
: base(source, declaredModelType: typeof(TModel))
|
||||||
{
|
{
|
||||||
|
if (source == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(source));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -65,9 +77,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
// Model parameter type is object to allow "model: null" calls even when TModel is a value type. A TModel
|
// Model parameter type is object to allow "model: null" calls even when TModel is a value type. A TModel
|
||||||
// parameter would likely require IEquatable<TModel> type restrictions to pass expected null value to the base
|
// parameter would likely require IEquatable<TModel> type restrictions to pass expected null value to the base
|
||||||
// constructor.
|
// constructor.
|
||||||
public ViewDataDictionary([NotNull] ViewDataDictionary source, object model)
|
public ViewDataDictionary(ViewDataDictionary source, object model)
|
||||||
: base(source, model, declaredModelType: typeof(TModel))
|
: base(source, model, declaredModelType: typeof(TModel))
|
||||||
{
|
{
|
||||||
|
if (source == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(source));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -75,9 +91,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>Internal for testing.</remarks>
|
/// <remarks>Internal for testing.</remarks>
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
internal ViewDataDictionary([NotNull] IModelMetadataProvider metadataProvider)
|
internal ViewDataDictionary(IModelMetadataProvider metadataProvider)
|
||||||
: base(metadataProvider, declaredModelType: typeof(TModel))
|
: base(metadataProvider, declaredModelType: typeof(TModel))
|
||||||
{
|
{
|
||||||
|
if (metadataProvider == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(metadataProvider));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public new TModel Model
|
public new TModel Model
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewFeatures
|
namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
{
|
{
|
||||||
|
|
@ -20,8 +20,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// <see cref="ViewDataInfo"/> for named <paramref name="expression"/> in given <paramref name="viewData"/>.
|
/// <see cref="ViewDataInfo"/> for named <paramref name="expression"/> in given <paramref name="viewData"/>.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static ViewDataInfo Eval([NotNull] ViewDataDictionary viewData, string expression)
|
public static ViewDataInfo Eval(ViewDataDictionary viewData, string expression)
|
||||||
{
|
{
|
||||||
|
if (viewData == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewData));
|
||||||
|
}
|
||||||
|
|
||||||
// While it is not valid to generate a field for the top-level model itself because the result is an
|
// While it is not valid to generate a field for the top-level model itself because the result is an
|
||||||
// unnamed input element, do not throw here if full name is null or empty. Support is needed for cases
|
// unnamed input element, do not throw here if full name is null or empty. Support is needed for cases
|
||||||
// such as Html.Label() and Html.Value(), where the user's code is not creating a name attribute. Checks
|
// such as Html.Label() and Html.Value(), where the user's code is not creating a name attribute. Checks
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Mvc.Rendering;
|
using Microsoft.AspNet.Mvc.Rendering;
|
||||||
using Microsoft.AspNet.Mvc.ViewEngines;
|
using Microsoft.AspNet.Mvc.ViewEngines;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
using Microsoft.Net.Http.Headers;
|
using Microsoft.Net.Http.Headers;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewFeatures
|
namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
|
|
@ -29,13 +29,38 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
/// <param name="tempData">The <see cref="ITempDataDictionary"/> for the view being rendered.</param>
|
/// <param name="tempData">The <see cref="ITempDataDictionary"/> for the view being rendered.</param>
|
||||||
/// <returns>A <see cref="Task"/> that represents the asynchronous rendering.</returns>
|
/// <returns>A <see cref="Task"/> that represents the asynchronous rendering.</returns>
|
||||||
public static async Task ExecuteAsync(
|
public static async Task ExecuteAsync(
|
||||||
[NotNull] IView view,
|
IView view,
|
||||||
[NotNull] ActionContext actionContext,
|
ActionContext actionContext,
|
||||||
[NotNull] ViewDataDictionary viewData,
|
ViewDataDictionary viewData,
|
||||||
[NotNull] ITempDataDictionary tempData,
|
ITempDataDictionary tempData,
|
||||||
[NotNull] HtmlHelperOptions htmlHelperOptions,
|
HtmlHelperOptions htmlHelperOptions,
|
||||||
MediaTypeHeaderValue contentType)
|
MediaTypeHeaderValue contentType)
|
||||||
{
|
{
|
||||||
|
if (view == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(view));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (actionContext == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(actionContext));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (viewData == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(viewData));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tempData == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(tempData));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (htmlHelperOptions == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(htmlHelperOptions));
|
||||||
|
}
|
||||||
|
|
||||||
var response = actionContext.HttpContext.Response;
|
var response = actionContext.HttpContext.Response;
|
||||||
|
|
||||||
if (contentType != null && contentType.Encoding == null)
|
if (contentType != null && contentType.Encoding == null)
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,9 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics.Tracing;
|
using System.Diagnostics.Tracing;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Mvc.Rendering;
|
|
||||||
using Microsoft.AspNet.Mvc.ViewEngines;
|
using Microsoft.AspNet.Mvc.ViewEngines;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
using Microsoft.AspNet.Mvc.ViewFeatures;
|
||||||
using Microsoft.Framework.DependencyInjection;
|
using Microsoft.Framework.DependencyInjection;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
using Microsoft.Framework.Logging;
|
using Microsoft.Framework.Logging;
|
||||||
using Microsoft.Framework.OptionsModel;
|
using Microsoft.Framework.OptionsModel;
|
||||||
using Microsoft.Net.Http.Headers;
|
using Microsoft.Net.Http.Headers;
|
||||||
|
|
@ -56,8 +54,13 @@ namespace Microsoft.AspNet.Mvc
|
||||||
public MediaTypeHeaderValue ContentType { get; set; }
|
public MediaTypeHeaderValue ContentType { get; set; }
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override async Task ExecuteResultAsync([NotNull] ActionContext context)
|
public override async Task ExecuteResultAsync(ActionContext context)
|
||||||
{
|
{
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(context));
|
||||||
|
}
|
||||||
|
|
||||||
var services = context.HttpContext.RequestServices;
|
var services = context.HttpContext.RequestServices;
|
||||||
var viewEngine = ViewEngine ?? services.GetRequiredService<ICompositeViewEngine>();
|
var viewEngine = ViewEngine ?? services.GetRequiredService<ICompositeViewEngine>();
|
||||||
|
|
||||||
|
|
@ -68,7 +71,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
|
|
||||||
var viewName = ViewName ?? context.ActionDescriptor.Name;
|
var viewName = ViewName ?? context.ActionDescriptor.Name;
|
||||||
var viewEngineResult = viewEngine.FindView(context, viewName);
|
var viewEngineResult = viewEngine.FindView(context, viewName);
|
||||||
if(!viewEngineResult.Success)
|
if (!viewEngineResult.Success)
|
||||||
{
|
{
|
||||||
if (telemetry.IsEnabled("Microsoft.AspNet.Mvc.ViewResultViewNotFound"))
|
if (telemetry.IsEnabled("Microsoft.AspNet.Mvc.ViewResultViewNotFound"))
|
||||||
{
|
{
|
||||||
|
|
@ -84,7 +87,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.LogError(
|
logger.LogError(
|
||||||
"The view '{ViewName}' was not found. Searched locations: {SearchedViewLocations}",
|
"The view '{ViewName}' was not found. Searched locations: {SearchedViewLocations}",
|
||||||
viewName,
|
viewName,
|
||||||
viewEngineResult.SearchedLocations);
|
viewEngineResult.SearchedLocations);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,21 +18,12 @@
|
||||||
"Microsoft.Framework.BufferedHtmlContent.Sources": { "version": "1.0.0-*", "type": "build" },
|
"Microsoft.Framework.BufferedHtmlContent.Sources": { "version": "1.0.0-*", "type": "build" },
|
||||||
"Microsoft.Framework.ClosedGenericMatcher.Sources": { "version": "1.0.0-*", "type": "build" },
|
"Microsoft.Framework.ClosedGenericMatcher.Sources": { "version": "1.0.0-*", "type": "build" },
|
||||||
"Microsoft.Framework.CopyOnWriteDictionary.Sources": { "version": "1.0.0-*", "type": "build" },
|
"Microsoft.Framework.CopyOnWriteDictionary.Sources": { "version": "1.0.0-*", "type": "build" },
|
||||||
"Microsoft.Framework.NotNullAttribute.Sources": { "version": "1.0.0-*", "type": "build" },
|
|
||||||
"Microsoft.Framework.PropertyActivator.Sources": { "version": "1.0.0-*", "type": "build" },
|
"Microsoft.Framework.PropertyActivator.Sources": { "version": "1.0.0-*", "type": "build" },
|
||||||
"Microsoft.Framework.PropertyHelper.Sources": { "version": "1.0.0-*", "type": "build" }
|
"Microsoft.Framework.PropertyHelper.Sources": { "version": "1.0.0-*", "type": "build" }
|
||||||
},
|
},
|
||||||
|
|
||||||
"frameworks": {
|
"frameworks": {
|
||||||
"dnx451": {
|
"dnx451": { },
|
||||||
"frameworkAssemblies": {
|
"dnxcore50": { }
|
||||||
"System.ComponentModel.DataAnnotations": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"dnxcore50": {
|
|
||||||
"dependencies": {
|
|
||||||
"System.ComponentModel.Annotations": "4.0.11-beta-*"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,15 @@ using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Html.Abstractions;
|
using Microsoft.AspNet.Html.Abstractions;
|
||||||
using Microsoft.AspNet.Http.Internal;
|
using Microsoft.AspNet.Http.Internal;
|
||||||
|
using Microsoft.AspNet.Mvc.Abstractions;
|
||||||
|
using Microsoft.AspNet.Mvc.ModelBinding;
|
||||||
using Microsoft.AspNet.Mvc.Rendering;
|
using Microsoft.AspNet.Mvc.Rendering;
|
||||||
using Microsoft.AspNet.Mvc.TestCommon;
|
using Microsoft.AspNet.Mvc.TestCommon;
|
||||||
using Microsoft.AspNet.Mvc.ViewEngines;
|
using Microsoft.AspNet.Mvc.ViewEngines;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
using Microsoft.AspNet.Mvc.ViewFeatures;
|
||||||
using Microsoft.AspNet.PageExecutionInstrumentation;
|
using Microsoft.AspNet.PageExecutionInstrumentation;
|
||||||
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
|
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
|
||||||
|
using Microsoft.AspNet.Routing;
|
||||||
using Microsoft.AspNet.Testing;
|
using Microsoft.AspNet.Testing;
|
||||||
using Microsoft.Framework.WebEncoders.Testing;
|
using Microsoft.Framework.WebEncoders.Testing;
|
||||||
using Moq;
|
using Moq;
|
||||||
|
|
@ -1827,11 +1830,14 @@ namespace Microsoft.AspNet.Mvc.Razor
|
||||||
private static ViewContext CreateViewContext(TextWriter writer = null)
|
private static ViewContext CreateViewContext(TextWriter writer = null)
|
||||||
{
|
{
|
||||||
writer = writer ?? new StringWriter();
|
writer = writer ?? new StringWriter();
|
||||||
var actionContext = new ActionContext(new DefaultHttpContext(), routeData: null, actionDescriptor: null);
|
var actionContext = new ActionContext(
|
||||||
|
new DefaultHttpContext(),
|
||||||
|
new RouteData(),
|
||||||
|
new ActionDescriptor());
|
||||||
return new ViewContext(
|
return new ViewContext(
|
||||||
actionContext,
|
actionContext,
|
||||||
Mock.Of<IView>(),
|
Mock.Of<IView>(),
|
||||||
null,
|
new ViewDataDictionary(new EmptyModelMetadataProvider()),
|
||||||
Mock.Of<ITempDataDictionary>(),
|
Mock.Of<ITempDataDictionary>(),
|
||||||
writer,
|
writer,
|
||||||
new HtmlHelperOptions());
|
new HtmlHelperOptions());
|
||||||
|
|
|
||||||
|
|
@ -297,14 +297,18 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
|
||||||
var pageFactory = new Mock<IRazorPageFactory>();
|
var pageFactory = new Mock<IRazorPageFactory>();
|
||||||
var viewFactory = new Mock<IRazorViewFactory>();
|
var viewFactory = new Mock<IRazorViewFactory>();
|
||||||
var page = Mock.Of<IRazorPage>();
|
var page = Mock.Of<IRazorPage>();
|
||||||
pageFactory.Setup(p => p.CreateInstance("fake-path1/bar/test-view.rzr"))
|
pageFactory
|
||||||
.Returns(Mock.Of<IRazorPage>())
|
.Setup(p => p.CreateInstance("fake-path1/bar/test-view.rzr"))
|
||||||
.Verifiable();
|
.Returns(page)
|
||||||
var viewEngine = new OverloadedLocationViewEngine(pageFactory.Object,
|
.Verifiable();
|
||||||
viewFactory.Object,
|
var viewEngine = new OverloadedLocationViewEngine(
|
||||||
GetOptionsAccessor(),
|
pageFactory.Object,
|
||||||
GetViewLocationCache());
|
viewFactory.Object,
|
||||||
|
GetOptionsAccessor(),
|
||||||
|
GetViewLocationCache());
|
||||||
var context = GetActionContext(_controllerTestContext);
|
var context = GetActionContext(_controllerTestContext);
|
||||||
|
viewFactory.Setup(v => v.GetView(viewEngine, page, false))
|
||||||
|
.Returns(Mock.Of<IView>());
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = viewEngine.FindView(context, "test-view");
|
var result = viewEngine.FindView(context, "test-view");
|
||||||
|
|
@ -320,14 +324,18 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
|
||||||
var pageFactory = new Mock<IRazorPageFactory>();
|
var pageFactory = new Mock<IRazorPageFactory>();
|
||||||
var viewFactory = new Mock<IRazorViewFactory>();
|
var viewFactory = new Mock<IRazorViewFactory>();
|
||||||
var page = Mock.Of<IRazorPage>();
|
var page = Mock.Of<IRazorPage>();
|
||||||
pageFactory.Setup(p => p.CreateInstance("fake-area-path/foo/bar/test-view2.rzr"))
|
pageFactory
|
||||||
.Returns(Mock.Of<IRazorPage>())
|
.Setup(p => p.CreateInstance("fake-area-path/foo/bar/test-view2.rzr"))
|
||||||
.Verifiable();
|
.Returns(page)
|
||||||
var viewEngine = new OverloadedLocationViewEngine(pageFactory.Object,
|
.Verifiable();
|
||||||
viewFactory.Object,
|
var viewEngine = new OverloadedLocationViewEngine(
|
||||||
GetOptionsAccessor(),
|
pageFactory.Object,
|
||||||
GetViewLocationCache());
|
viewFactory.Object,
|
||||||
|
GetOptionsAccessor(),
|
||||||
|
GetViewLocationCache());
|
||||||
var context = GetActionContext(_areaTestContext);
|
var context = GetActionContext(_areaTestContext);
|
||||||
|
viewFactory.Setup(v => v.GetView(viewEngine, page, false))
|
||||||
|
.Returns(Mock.Of<IView>());
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = viewEngine.FindView(context, "test-view2");
|
var result = viewEngine.FindView(context, "test-view2");
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,12 @@ using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Http.Features;
|
using Microsoft.AspNet.Http.Features;
|
||||||
using Microsoft.AspNet.Http.Internal;
|
using Microsoft.AspNet.Http.Internal;
|
||||||
|
using Microsoft.AspNet.Mvc.Abstractions;
|
||||||
using Microsoft.AspNet.Mvc.ModelBinding;
|
using Microsoft.AspNet.Mvc.ModelBinding;
|
||||||
using Microsoft.AspNet.Mvc.Rendering;
|
using Microsoft.AspNet.Mvc.Rendering;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
using Microsoft.AspNet.Mvc.ViewFeatures;
|
||||||
using Microsoft.AspNet.PageExecutionInstrumentation;
|
using Microsoft.AspNet.PageExecutionInstrumentation;
|
||||||
|
using Microsoft.AspNet.Routing;
|
||||||
using Microsoft.Framework.WebEncoders.Testing;
|
using Microsoft.Framework.WebEncoders.Testing;
|
||||||
using Moq;
|
using Moq;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
@ -1404,12 +1406,13 @@ namespace Microsoft.AspNet.Mvc.Razor
|
||||||
viewEngine.Setup(p => p.FindPage(It.IsAny<ActionContext>(), "/Layout.cshtml"))
|
viewEngine.Setup(p => p.FindPage(It.IsAny<ActionContext>(), "/Layout.cshtml"))
|
||||||
.Returns(new RazorPageResult("Layout", layout));
|
.Returns(new RazorPageResult("Layout", layout));
|
||||||
|
|
||||||
var view = new RazorView(viewEngine.Object,
|
var view = new RazorView(
|
||||||
Mock.Of<IRazorPageActivator>(),
|
viewEngine.Object,
|
||||||
CreateViewStartProvider(viewStart),
|
Mock.Of<IRazorPageActivator>(),
|
||||||
page,
|
CreateViewStartProvider(viewStart),
|
||||||
new CommonTestEncoder(),
|
page,
|
||||||
isPartial: false);
|
new CommonTestEncoder(),
|
||||||
|
isPartial: false);
|
||||||
var viewContext = CreateViewContext(view);
|
var viewContext = CreateViewContext(view);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -1457,7 +1460,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
||||||
private static ViewContext CreateViewContext(RazorView view)
|
private static ViewContext CreateViewContext(RazorView view)
|
||||||
{
|
{
|
||||||
var httpContext = new DefaultHttpContext();
|
var httpContext = new DefaultHttpContext();
|
||||||
var actionContext = new ActionContext(httpContext, routeData: null, actionDescriptor: null);
|
var actionContext = new ActionContext(httpContext, new RouteData(), new ActionDescriptor());
|
||||||
return new ViewContext(
|
return new ViewContext(
|
||||||
actionContext,
|
actionContext,
|
||||||
view,
|
view,
|
||||||
|
|
@ -1471,8 +1474,9 @@ namespace Microsoft.AspNet.Mvc.Razor
|
||||||
{
|
{
|
||||||
viewStartPages = viewStartPages ?? new IRazorPage[0];
|
viewStartPages = viewStartPages ?? new IRazorPage[0];
|
||||||
var viewStartProvider = new Mock<IViewStartProvider>();
|
var viewStartProvider = new Mock<IViewStartProvider>();
|
||||||
viewStartProvider.Setup(v => v.GetViewStartPages(It.IsAny<string>()))
|
viewStartProvider
|
||||||
.Returns(viewStartPages);
|
.Setup(v => v.GetViewStartPages(It.IsAny<string>()))
|
||||||
|
.Returns(viewStartPages);
|
||||||
|
|
||||||
return viewStartProvider.Object;
|
return viewStartProvider.Object;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ using Microsoft.AspNet.Http;
|
||||||
using Microsoft.AspNet.Http.Internal;
|
using Microsoft.AspNet.Http.Internal;
|
||||||
using Microsoft.AspNet.Mvc.Abstractions;
|
using Microsoft.AspNet.Mvc.Abstractions;
|
||||||
using Microsoft.AspNet.Mvc.Filters;
|
using Microsoft.AspNet.Mvc.Filters;
|
||||||
|
using Microsoft.AspNet.Mvc.Formatters;
|
||||||
using Microsoft.AspNet.Mvc.ModelBinding;
|
using Microsoft.AspNet.Mvc.ModelBinding;
|
||||||
using Microsoft.AspNet.Mvc.ModelBinding.Validation;
|
using Microsoft.AspNet.Mvc.ModelBinding.Validation;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
using Microsoft.AspNet.Mvc.ViewFeatures;
|
||||||
|
|
@ -1753,6 +1754,7 @@ namespace Microsoft.AspNet.Mvc.Test
|
||||||
{
|
{
|
||||||
ModelBinder = binder,
|
ModelBinder = binder,
|
||||||
ValueProvider = provider,
|
ValueProvider = provider,
|
||||||
|
InputFormatters = new List<IInputFormatter>(),
|
||||||
ValidatorProvider = new DataAnnotationsModelValidatorProvider(
|
ValidatorProvider = new DataAnnotationsModelValidatorProvider(
|
||||||
options: null,
|
options: null,
|
||||||
stringLocalizerFactory: null)
|
stringLocalizerFactory: null)
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,9 @@ using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Http;
|
using Microsoft.AspNet.Http;
|
||||||
using Microsoft.AspNet.Http.Internal;
|
using Microsoft.AspNet.Http.Internal;
|
||||||
using Microsoft.AspNet.Mvc.Abstractions;
|
using Microsoft.AspNet.Mvc.Abstractions;
|
||||||
|
using Microsoft.AspNet.Mvc.ModelBinding;
|
||||||
using Microsoft.AspNet.Mvc.ViewEngines;
|
using Microsoft.AspNet.Mvc.ViewEngines;
|
||||||
|
using Microsoft.AspNet.Mvc.ViewFeatures;
|
||||||
using Microsoft.AspNet.Routing;
|
using Microsoft.AspNet.Routing;
|
||||||
using Microsoft.Framework.Logging;
|
using Microsoft.Framework.Logging;
|
||||||
using Microsoft.Framework.OptionsModel;
|
using Microsoft.Framework.OptionsModel;
|
||||||
|
|
@ -23,27 +25,32 @@ namespace Microsoft.AspNet.Mvc
|
||||||
public async Task ExecuteResultAsync_ReturnsError_IfViewCouldNotBeFound()
|
public async Task ExecuteResultAsync_ReturnsError_IfViewCouldNotBeFound()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var expected = string.Join(Environment.NewLine,
|
var expected = string.Join(
|
||||||
"The view 'MyView' was not found. The following locations were searched:",
|
Environment.NewLine,
|
||||||
"Location1",
|
"The view 'MyView' was not found. The following locations were searched:",
|
||||||
"Location2.");
|
"Location1",
|
||||||
var actionContext = new ActionContext(GetHttpContext(),
|
"Location2.");
|
||||||
new RouteData(),
|
var actionContext = new ActionContext(
|
||||||
new ActionDescriptor());
|
GetHttpContext(),
|
||||||
|
new RouteData(),
|
||||||
|
new ActionDescriptor());
|
||||||
var viewEngine = new Mock<IViewEngine>();
|
var viewEngine = new Mock<IViewEngine>();
|
||||||
viewEngine.Setup(v => v.FindPartialView(It.IsAny<ActionContext>(), It.IsAny<string>()))
|
viewEngine
|
||||||
.Returns(ViewEngineResult.NotFound("MyView", new[] { "Location1", "Location2" }))
|
.Setup(v => v.FindPartialView(It.IsAny<ActionContext>(), It.IsAny<string>()))
|
||||||
.Verifiable();
|
.Returns(ViewEngineResult.NotFound("MyView", new[] { "Location1", "Location2" }))
|
||||||
|
.Verifiable();
|
||||||
|
|
||||||
var viewResult = new PartialViewResult
|
var viewResult = new PartialViewResult
|
||||||
{
|
{
|
||||||
ViewEngine = viewEngine.Object,
|
ViewEngine = viewEngine.Object,
|
||||||
ViewName = "MyView"
|
ViewName = "MyView",
|
||||||
|
ViewData = new ViewDataDictionary(new EmptyModelMetadataProvider()),
|
||||||
|
TempData = Mock.Of<ITempDataDictionary>(),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act and Assert
|
// Act and Assert
|
||||||
var ex = await Assert.ThrowsAsync<InvalidOperationException>(
|
var ex = await Assert.ThrowsAsync<InvalidOperationException>(
|
||||||
() => viewResult.ExecuteResultAsync(actionContext));
|
() => viewResult.ExecuteResultAsync(actionContext));
|
||||||
Assert.Equal(expected, ex.Message);
|
Assert.Equal(expected, ex.Message);
|
||||||
viewEngine.Verify();
|
viewEngine.Verify();
|
||||||
}
|
}
|
||||||
|
|
@ -57,14 +64,17 @@ namespace Microsoft.AspNet.Mvc
|
||||||
var viewEngine = new Mock<IViewEngine>();
|
var viewEngine = new Mock<IViewEngine>();
|
||||||
var view = Mock.Of<IView>();
|
var view = Mock.Of<IView>();
|
||||||
|
|
||||||
viewEngine.Setup(e => e.FindPartialView(context, "myview"))
|
viewEngine
|
||||||
.Returns(ViewEngineResult.Found("myview", view))
|
.Setup(e => e.FindPartialView(context, "myview"))
|
||||||
.Verifiable();
|
.Returns(ViewEngineResult.Found("myview", view))
|
||||||
|
.Verifiable();
|
||||||
|
|
||||||
var viewResult = new PartialViewResult
|
var viewResult = new PartialViewResult
|
||||||
{
|
{
|
||||||
ViewName = viewName,
|
ViewName = viewName,
|
||||||
ViewEngine = viewEngine.Object
|
ViewEngine = viewEngine.Object,
|
||||||
|
ViewData = new ViewDataDictionary(new EmptyModelMetadataProvider()),
|
||||||
|
TempData = Mock.Of<ITempDataDictionary>(),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -109,14 +119,17 @@ namespace Microsoft.AspNet.Mvc
|
||||||
var viewEngine = new Mock<IViewEngine>();
|
var viewEngine = new Mock<IViewEngine>();
|
||||||
var view = Mock.Of<IView>();
|
var view = Mock.Of<IView>();
|
||||||
|
|
||||||
viewEngine.Setup(e => e.FindPartialView(context, "myview"))
|
viewEngine
|
||||||
.Returns(ViewEngineResult.Found("myview", view));
|
.Setup(e => e.FindPartialView(context, "myview"))
|
||||||
|
.Returns(ViewEngineResult.Found("myview", view));
|
||||||
|
|
||||||
var viewResult = new PartialViewResult
|
var viewResult = new PartialViewResult
|
||||||
{
|
{
|
||||||
ViewName = viewName,
|
ViewName = viewName,
|
||||||
ViewEngine = viewEngine.Object,
|
ViewEngine = viewEngine.Object,
|
||||||
ContentType = contentType
|
ContentType = contentType,
|
||||||
|
ViewData = new ViewDataDictionary(new EmptyModelMetadataProvider()),
|
||||||
|
TempData = Mock.Of<ITempDataDictionary>(),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -136,14 +149,17 @@ namespace Microsoft.AspNet.Mvc
|
||||||
var viewEngine = new Mock<IViewEngine>();
|
var viewEngine = new Mock<IViewEngine>();
|
||||||
var view = Mock.Of<IView>();
|
var view = Mock.Of<IView>();
|
||||||
|
|
||||||
viewEngine.Setup(e => e.FindPartialView(context, "myview"))
|
viewEngine
|
||||||
.Returns(ViewEngineResult.Found("myview", view));
|
.Setup(e => e.FindPartialView(context, "myview"))
|
||||||
|
.Returns(ViewEngineResult.Found("myview", view));
|
||||||
|
|
||||||
var viewResult = new PartialViewResult
|
var viewResult = new PartialViewResult
|
||||||
{
|
{
|
||||||
ViewName = viewName,
|
ViewName = viewName,
|
||||||
ViewEngine = viewEngine.Object,
|
ViewEngine = viewEngine.Object,
|
||||||
StatusCode = 404,
|
StatusCode = 404,
|
||||||
|
ViewData = new ViewDataDictionary(new EmptyModelMetadataProvider()),
|
||||||
|
TempData = Mock.Of<ITempDataDictionary>(),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -158,17 +174,21 @@ namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var viewName = "some-view-name";
|
var viewName = "some-view-name";
|
||||||
var context = new ActionContext(GetHttpContext(),
|
var context = new ActionContext(
|
||||||
new RouteData(),
|
GetHttpContext(),
|
||||||
new ActionDescriptor { Name = viewName });
|
new RouteData(),
|
||||||
|
new ActionDescriptor { Name = viewName });
|
||||||
var viewEngine = new Mock<ICompositeViewEngine>();
|
var viewEngine = new Mock<ICompositeViewEngine>();
|
||||||
viewEngine.Setup(e => e.FindPartialView(context, viewName))
|
viewEngine
|
||||||
.Returns(ViewEngineResult.Found(viewName, Mock.Of<IView>()))
|
.Setup(e => e.FindPartialView(context, viewName))
|
||||||
.Verifiable();
|
.Returns(ViewEngineResult.Found(viewName, Mock.Of<IView>()))
|
||||||
|
.Verifiable();
|
||||||
|
|
||||||
var viewResult = new PartialViewResult
|
var viewResult = new PartialViewResult
|
||||||
{
|
{
|
||||||
ViewEngine = viewEngine.Object
|
ViewEngine = viewEngine.Object,
|
||||||
|
ViewData = new ViewDataDictionary(new EmptyModelMetadataProvider()),
|
||||||
|
TempData = Mock.Of<ITempDataDictionary>(),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -183,19 +203,23 @@ namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var viewName = "partial-view-name";
|
var viewName = "partial-view-name";
|
||||||
var context = new ActionContext(new DefaultHttpContext(),
|
var context = new ActionContext(
|
||||||
new RouteData(),
|
new DefaultHttpContext(),
|
||||||
new ActionDescriptor { Name = viewName });
|
new RouteData(),
|
||||||
|
new ActionDescriptor { Name = viewName });
|
||||||
var viewEngine = new Mock<ICompositeViewEngine>();
|
var viewEngine = new Mock<ICompositeViewEngine>();
|
||||||
viewEngine.Setup(e => e.FindPartialView(It.IsAny<ActionContext>(), viewName))
|
viewEngine
|
||||||
.Returns(ViewEngineResult.Found(viewName, Mock.Of<IView>()))
|
.Setup(e => e.FindPartialView(It.IsAny<ActionContext>(), viewName))
|
||||||
.Verifiable();
|
.Returns(ViewEngineResult.Found(viewName, Mock.Of<IView>()))
|
||||||
|
.Verifiable();
|
||||||
|
|
||||||
var serviceProvider = new Mock<IServiceProvider>();
|
var serviceProvider = new Mock<IServiceProvider>();
|
||||||
serviceProvider.Setup(p => p.GetService(typeof(ICompositeViewEngine)))
|
serviceProvider
|
||||||
.Returns(viewEngine.Object);
|
.Setup(p => p.GetService(typeof(ICompositeViewEngine)))
|
||||||
serviceProvider.Setup(p => p.GetService(typeof(ILogger<PartialViewResult>)))
|
.Returns(viewEngine.Object);
|
||||||
.Returns(new Mock<ILogger<PartialViewResult>>().Object);
|
serviceProvider
|
||||||
|
.Setup(p => p.GetService(typeof(ILogger<PartialViewResult>)))
|
||||||
|
.Returns(new Mock<ILogger<PartialViewResult>>().Object);
|
||||||
serviceProvider.Setup(s => s.GetService(typeof(IOptions<MvcViewOptions>)))
|
serviceProvider.Setup(s => s.GetService(typeof(IOptions<MvcViewOptions>)))
|
||||||
.Returns(() => {
|
.Returns(() => {
|
||||||
var optionsAccessor = new Mock<IOptions<MvcViewOptions>>();
|
var optionsAccessor = new Mock<IOptions<MvcViewOptions>>();
|
||||||
|
|
@ -207,7 +231,9 @@ namespace Microsoft.AspNet.Mvc
|
||||||
|
|
||||||
var viewResult = new PartialViewResult
|
var viewResult = new PartialViewResult
|
||||||
{
|
{
|
||||||
ViewName = viewName
|
ViewName = viewName,
|
||||||
|
ViewData = new ViewDataDictionary(new EmptyModelMetadataProvider()),
|
||||||
|
TempData = Mock.Of<ITempDataDictionary>(),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
|
||||||
|
|
@ -285,7 +285,9 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
actionContext,
|
actionContext,
|
||||||
Mock.Of<IView>(),
|
Mock.Of<IView>(),
|
||||||
viewData,
|
viewData,
|
||||||
null,
|
new TempDataDictionary(
|
||||||
|
new HttpContextAccessor(),
|
||||||
|
Mock.Of<ITempDataProvider>()),
|
||||||
new StringWriter(),
|
new StringWriter(),
|
||||||
options.HtmlHelperOptions);
|
options.HtmlHelperOptions);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ using Microsoft.AspNet.Mvc.TestCommon;
|
||||||
using Microsoft.AspNet.Mvc.ViewEngines;
|
using Microsoft.AspNet.Mvc.ViewEngines;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
using Microsoft.AspNet.Mvc.ViewFeatures;
|
||||||
using Microsoft.AspNet.Testing;
|
using Microsoft.AspNet.Testing;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
using Microsoft.Framework.WebEncoders;
|
using Microsoft.Framework.WebEncoders;
|
||||||
using Moq;
|
using Moq;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
@ -1563,7 +1562,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
|
|
||||||
private class TestHtmlHelper : HtmlHelper
|
private class TestHtmlHelper : HtmlHelper
|
||||||
{
|
{
|
||||||
public TestHtmlHelper([NotNull] IModelMetadataProvider metadataProvider)
|
public TestHtmlHelper(IModelMetadataProvider metadataProvider)
|
||||||
: base(
|
: base(
|
||||||
new Mock<IHtmlGenerator>(MockBehavior.Strict).Object,
|
new Mock<IHtmlGenerator>(MockBehavior.Strict).Object,
|
||||||
new Mock<ICompositeViewEngine>(MockBehavior.Strict).Object,
|
new Mock<ICompositeViewEngine>(MockBehavior.Strict).Object,
|
||||||
|
|
@ -1580,7 +1579,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
|
|
||||||
public IEnumerable<SelectListItem> CopiedSelectListItems { get; private set; }
|
public IEnumerable<SelectListItem> CopiedSelectListItems { get; private set; }
|
||||||
|
|
||||||
protected override IEnumerable<SelectListItem> GetEnumSelectList([NotNull] ModelMetadata metadata)
|
protected override IEnumerable<SelectListItem> GetEnumSelectList(ModelMetadata metadata)
|
||||||
{
|
{
|
||||||
Metadata = metadata;
|
Metadata = metadata;
|
||||||
SelectListItems = base.GetEnumSelectList(metadata);
|
SelectListItems = base.GetEnumSelectList(metadata);
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,14 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System.IO;
|
||||||
|
using Microsoft.AspNet.Http.Internal;
|
||||||
|
using Microsoft.AspNet.Mvc.Abstractions;
|
||||||
using Microsoft.AspNet.Mvc.ModelBinding;
|
using Microsoft.AspNet.Mvc.ModelBinding;
|
||||||
|
using Microsoft.AspNet.Mvc.ViewEngines;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
using Microsoft.AspNet.Mvc.ViewFeatures;
|
||||||
|
using Microsoft.AspNet.Routing;
|
||||||
|
using Moq;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.Rendering
|
namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
|
|
@ -12,15 +18,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
[Fact]
|
[Fact]
|
||||||
public void SettingViewData_AlsoUpdatesViewBag()
|
public void SettingViewData_AlsoUpdatesViewBag()
|
||||||
{
|
{
|
||||||
// Arrange (eventually passing null to these consturctors will throw)
|
// Arrange
|
||||||
|
var originalViewData = new ViewDataDictionary(metadataProvider: new EmptyModelMetadataProvider());
|
||||||
var context = new ViewContext(
|
var context = new ViewContext(
|
||||||
new ActionContext(null, null, null),
|
new ActionContext(new DefaultHttpContext(), new RouteData(), new ActionDescriptor()),
|
||||||
view: null,
|
view: Mock.Of<IView>(),
|
||||||
viewData: null,
|
viewData: originalViewData,
|
||||||
tempData: null,
|
tempData: new TempDataDictionary(new HttpContextAccessor(), Mock.Of<ITempDataProvider>()),
|
||||||
writer: null,
|
writer: TextWriter.Null,
|
||||||
htmlHelperOptions: new HtmlHelperOptions());
|
htmlHelperOptions: new HtmlHelperOptions());
|
||||||
var originalViewData = context.ViewData = new ViewDataDictionary(metadataProvider: new EmptyModelMetadataProvider());
|
|
||||||
var replacementViewData = new ViewDataDictionary(metadataProvider: new EmptyModelMetadataProvider());
|
var replacementViewData = new ViewDataDictionary(metadataProvider: new EmptyModelMetadataProvider());
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
|
||||||
|
|
@ -13,28 +13,34 @@ using Microsoft.AspNet.Mvc.Infrastructure;
|
||||||
using Microsoft.AspNet.Mvc.ModelBinding;
|
using Microsoft.AspNet.Mvc.ModelBinding;
|
||||||
using Microsoft.AspNet.Mvc.Rendering;
|
using Microsoft.AspNet.Mvc.Rendering;
|
||||||
using Microsoft.AspNet.Mvc.ViewComponents;
|
using Microsoft.AspNet.Mvc.ViewComponents;
|
||||||
|
using Microsoft.AspNet.Mvc.ViewFeatures;
|
||||||
using Microsoft.AspNet.Routing;
|
using Microsoft.AspNet.Routing;
|
||||||
using Microsoft.Framework.DependencyInjection;
|
using Microsoft.Framework.DependencyInjection;
|
||||||
using Microsoft.Framework.OptionsModel;
|
using Microsoft.Framework.OptionsModel;
|
||||||
using Microsoft.Net.Http.Headers;
|
using Microsoft.Net.Http.Headers;
|
||||||
using Moq;
|
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc
|
namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
public class ViewComponentResultTest
|
public class ViewComponentResultTest
|
||||||
{
|
{
|
||||||
|
private readonly ITempDataDictionary _tempDataDictionary =
|
||||||
|
new TempDataDictionary(new HttpContextAccessor(), new SessionStateTempDataProvider());
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task ExecuteResultAsync_Throws_IfNameOrTypeIsNotSet()
|
public async Task ExecuteResultAsync_Throws_IfNameOrTypeIsNotSet()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var expected =
|
var expected =
|
||||||
"Either the 'ViewComponentName' or 'ViewComponentType' " +
|
"Either the 'ViewComponentName' or 'ViewComponentType' " +
|
||||||
"property must be set in order to invoke a view component.";
|
"property must be set in order to invoke a view component.";
|
||||||
|
|
||||||
var actionContext = CreateActionContext();
|
var actionContext = CreateActionContext();
|
||||||
|
|
||||||
var viewComponentResult = new ViewComponentResult();
|
var viewComponentResult = new ViewComponentResult
|
||||||
|
{
|
||||||
|
TempData = _tempDataDictionary,
|
||||||
|
};
|
||||||
|
|
||||||
// Act and Assert
|
// Act and Assert
|
||||||
var exception = await Assert.ThrowsAsync<InvalidOperationException>(
|
var exception = await Assert.ThrowsAsync<InvalidOperationException>(
|
||||||
|
|
@ -53,6 +59,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
var viewComponentResult = new ViewComponentResult
|
var viewComponentResult = new ViewComponentResult
|
||||||
{
|
{
|
||||||
ViewComponentName = "Text",
|
ViewComponentName = "Text",
|
||||||
|
TempData = _tempDataDictionary,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act and Assert
|
// Act and Assert
|
||||||
|
|
@ -75,6 +82,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
var viewComponentResult = new ViewComponentResult
|
var viewComponentResult = new ViewComponentResult
|
||||||
{
|
{
|
||||||
ViewComponentType = typeof(TextViewComponent),
|
ViewComponentType = typeof(TextViewComponent),
|
||||||
|
TempData = _tempDataDictionary,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act and Assert
|
// Act and Assert
|
||||||
|
|
@ -100,6 +108,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
Arguments = new object[] { "World!" },
|
Arguments = new object[] { "World!" },
|
||||||
ViewComponentName = "Text",
|
ViewComponentName = "Text",
|
||||||
|
TempData = _tempDataDictionary,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -127,6 +136,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
Arguments = new object[] { "World!" },
|
Arguments = new object[] { "World!" },
|
||||||
ViewComponentName = "AsyncText",
|
ViewComponentName = "AsyncText",
|
||||||
|
TempData = _tempDataDictionary,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -154,6 +164,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
Arguments = new object[] { "World!" },
|
Arguments = new object[] { "World!" },
|
||||||
ViewComponentName = "Text",
|
ViewComponentName = "Text",
|
||||||
|
TempData = _tempDataDictionary,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -181,6 +192,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
Arguments = new object[] { "World!" },
|
Arguments = new object[] { "World!" },
|
||||||
ViewComponentName = "Full.Name.Text",
|
ViewComponentName = "Full.Name.Text",
|
||||||
|
TempData = _tempDataDictionary,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -208,6 +220,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
Arguments = new object[] { "World!" },
|
Arguments = new object[] { "World!" },
|
||||||
ViewComponentType = typeof(TextViewComponent),
|
ViewComponentType = typeof(TextViewComponent),
|
||||||
|
TempData = _tempDataDictionary,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -236,6 +249,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
Arguments = new object[] { "World!" },
|
Arguments = new object[] { "World!" },
|
||||||
ViewComponentType = typeof(TextViewComponent),
|
ViewComponentType = typeof(TextViewComponent),
|
||||||
StatusCode = 404,
|
StatusCode = 404,
|
||||||
|
TempData = _tempDataDictionary,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -293,7 +307,8 @@ namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
Arguments = new object[] { "World!" },
|
Arguments = new object[] { "World!" },
|
||||||
ViewComponentName = "Text",
|
ViewComponentName = "Text",
|
||||||
ContentType = contentType
|
ContentType = contentType,
|
||||||
|
TempData = _tempDataDictionary,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -330,6 +345,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
Arguments = new object[] { "World!" },
|
Arguments = new object[] { "World!" },
|
||||||
ViewComponentName = "Text",
|
ViewComponentName = "Text",
|
||||||
ContentType = new MediaTypeHeaderValue("text/html") { Encoding = Encoding.UTF8 },
|
ContentType = new MediaTypeHeaderValue("text/html") { Encoding = Encoding.UTF8 },
|
||||||
|
TempData = _tempDataDictionary,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -359,6 +375,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
Arguments = new object[] { "World!" },
|
Arguments = new object[] { "World!" },
|
||||||
ViewComponentName = "Text",
|
ViewComponentName = "Text",
|
||||||
|
TempData = _tempDataDictionary,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,8 @@ namespace Microsoft.AspNet.Mvc
|
||||||
var viewContext = new ViewContext(
|
var viewContext = new ViewContext(
|
||||||
actionContext,
|
actionContext,
|
||||||
view,
|
view,
|
||||||
viewData, null,
|
viewData,
|
||||||
|
new TempDataDictionary(new HttpContextAccessor(), new SessionStateTempDataProvider()),
|
||||||
TextWriter.Null,
|
TextWriter.Null,
|
||||||
new HtmlHelperOptions());
|
new HtmlHelperOptions());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Microsoft.AspNet.Mvc.Infrastructure;
|
using Microsoft.AspNet.Mvc.Infrastructure;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ViewComponents
|
namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
|
|
@ -187,7 +186,7 @@ namespace Microsoft.AspNet.Mvc.ViewComponents
|
||||||
|
|
||||||
public Type[] AllowedTypes { get; private set; }
|
public Type[] AllowedTypes { get; private set; }
|
||||||
|
|
||||||
protected override bool IsViewComponentType([NotNull] TypeInfo typeInfo)
|
protected override bool IsViewComponentType(TypeInfo typeInfo)
|
||||||
{
|
{
|
||||||
return AllowedTypes.Contains(typeInfo.AsType());
|
return AllowedTypes.Contains(typeInfo.AsType());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
actionContext,
|
actionContext,
|
||||||
view,
|
view,
|
||||||
viewData,
|
viewData,
|
||||||
null,
|
Mock.Of<ITempDataDictionary>(),
|
||||||
TextWriter.Null,
|
TextWriter.Null,
|
||||||
new HtmlHelperOptions());
|
new HtmlHelperOptions());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,9 @@ namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
public class ViewViewComponentResultTest
|
public class ViewViewComponentResultTest
|
||||||
{
|
{
|
||||||
|
private readonly ITempDataDictionary _tempDataDictionary =
|
||||||
|
new TempDataDictionary(new HttpContextAccessor(), new SessionStateTempDataProvider());
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Execute_RendersPartialViews()
|
public void Execute_RendersPartialViews()
|
||||||
{
|
{
|
||||||
|
|
@ -40,7 +43,8 @@ namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
ViewEngine = viewEngine.Object,
|
ViewEngine = viewEngine.Object,
|
||||||
ViewName = "some-view",
|
ViewName = "some-view",
|
||||||
ViewData = viewData
|
ViewData = viewData,
|
||||||
|
TempData = _tempDataDictionary,
|
||||||
};
|
};
|
||||||
|
|
||||||
var viewComponentContext = GetViewComponentContext(view.Object, viewData);
|
var viewComponentContext = GetViewComponentContext(view.Object, viewData);
|
||||||
|
|
@ -72,7 +76,8 @@ namespace Microsoft.AspNet.Mvc
|
||||||
var result = new ViewViewComponentResult
|
var result = new ViewViewComponentResult
|
||||||
{
|
{
|
||||||
ViewEngine = viewEngine.Object,
|
ViewEngine = viewEngine.Object,
|
||||||
ViewData = viewData
|
ViewData = viewData,
|
||||||
|
TempData = _tempDataDictionary,
|
||||||
};
|
};
|
||||||
|
|
||||||
var viewComponentContext = GetViewComponentContext(view.Object, viewData);
|
var viewComponentContext = GetViewComponentContext(view.Object, viewData);
|
||||||
|
|
@ -107,7 +112,8 @@ namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
ViewEngine = viewEngine.Object,
|
ViewEngine = viewEngine.Object,
|
||||||
ViewName = "some-view",
|
ViewName = "some-view",
|
||||||
ViewData = viewData
|
ViewData = viewData,
|
||||||
|
TempData = _tempDataDictionary,
|
||||||
};
|
};
|
||||||
|
|
||||||
var viewComponentContext = GetViewComponentContext(view, viewData);
|
var viewComponentContext = GetViewComponentContext(view, viewData);
|
||||||
|
|
@ -139,7 +145,8 @@ namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
ViewEngine = viewEngine.Object,
|
ViewEngine = viewEngine.Object,
|
||||||
ViewName = "some-view",
|
ViewName = "some-view",
|
||||||
ViewData = viewData
|
ViewData = viewData,
|
||||||
|
TempData = _tempDataDictionary,
|
||||||
};
|
};
|
||||||
|
|
||||||
var viewComponentContext = GetViewComponentContext(view.Object, viewData);
|
var viewComponentContext = GetViewComponentContext(view.Object, viewData);
|
||||||
|
|
@ -169,7 +176,8 @@ namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
ViewEngine = viewEngine.Object,
|
ViewEngine = viewEngine.Object,
|
||||||
ViewName = "some-view",
|
ViewName = "some-view",
|
||||||
ViewData = viewData
|
ViewData = viewData,
|
||||||
|
TempData = _tempDataDictionary,
|
||||||
};
|
};
|
||||||
|
|
||||||
var viewComponentContext = GetViewComponentContext(view, viewData);
|
var viewComponentContext = GetViewComponentContext(view, viewData);
|
||||||
|
|
@ -201,7 +209,8 @@ namespace Microsoft.AspNet.Mvc
|
||||||
var result = new ViewViewComponentResult
|
var result = new ViewViewComponentResult
|
||||||
{
|
{
|
||||||
ViewName = "some-view",
|
ViewName = "some-view",
|
||||||
ViewData = viewData
|
ViewData = viewData,
|
||||||
|
TempData = _tempDataDictionary,
|
||||||
};
|
};
|
||||||
|
|
||||||
var viewComponentContext = GetViewComponentContext(view, viewData);
|
var viewComponentContext = GetViewComponentContext(view, viewData);
|
||||||
|
|
@ -239,7 +248,8 @@ namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
ViewEngine = viewEngine.Object,
|
ViewEngine = viewEngine.Object,
|
||||||
ViewName = "some-view",
|
ViewName = "some-view",
|
||||||
ViewData = viewData
|
ViewData = viewData,
|
||||||
|
TempData = _tempDataDictionary,
|
||||||
};
|
};
|
||||||
|
|
||||||
var viewComponentContext = GetViewComponentContext(view, viewData);
|
var viewComponentContext = GetViewComponentContext(view, viewData);
|
||||||
|
|
@ -266,7 +276,8 @@ namespace Microsoft.AspNet.Mvc
|
||||||
var result = new ViewViewComponentResult
|
var result = new ViewViewComponentResult
|
||||||
{
|
{
|
||||||
ViewName = "some-view",
|
ViewName = "some-view",
|
||||||
ViewData = viewData
|
ViewData = viewData,
|
||||||
|
TempData = _tempDataDictionary,
|
||||||
};
|
};
|
||||||
|
|
||||||
var viewComponentContext = GetViewComponentContext(view, viewData);
|
var viewComponentContext = GetViewComponentContext(view, viewData);
|
||||||
|
|
@ -299,6 +310,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
componentResult.ViewEngine = viewEngine.Object;
|
componentResult.ViewEngine = viewEngine.Object;
|
||||||
componentResult.ViewData = viewData;
|
componentResult.ViewData = viewData;
|
||||||
componentResult.ViewName = viewName;
|
componentResult.ViewName = viewName;
|
||||||
|
componentResult.TempData = _tempDataDictionary;
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
componentResult.Execute(componentContext);
|
componentResult.Execute(componentContext);
|
||||||
|
|
@ -323,7 +335,8 @@ namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
ViewEngine = viewEngine.Object,
|
ViewEngine = viewEngine.Object,
|
||||||
ViewData = viewData,
|
ViewData = viewData,
|
||||||
ViewName = viewName
|
ViewName = viewName,
|
||||||
|
TempData = _tempDataDictionary,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
|
|
@ -338,7 +351,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
actionContext,
|
actionContext,
|
||||||
view,
|
view,
|
||||||
viewData,
|
viewData,
|
||||||
null,
|
new TempDataDictionary(new HttpContextAccessor(), new SessionStateTempDataProvider()),
|
||||||
TextWriter.Null,
|
TextWriter.Null,
|
||||||
new HtmlHelperOptions());
|
new HtmlHelperOptions());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ using Microsoft.AspNet.Mvc.TestCommon;
|
||||||
using Microsoft.AspNet.Mvc.ViewEngines;
|
using Microsoft.AspNet.Mvc.ViewEngines;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures.Internal;
|
using Microsoft.AspNet.Mvc.ViewFeatures.Internal;
|
||||||
using Microsoft.AspNet.Testing;
|
using Microsoft.AspNet.Testing;
|
||||||
using Microsoft.Framework.Internal;
|
|
||||||
using Microsoft.Framework.WebEncoders;
|
using Microsoft.Framework.WebEncoders;
|
||||||
using Moq;
|
using Moq;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
@ -426,7 +425,7 @@ Environment.NewLine;
|
||||||
|
|
||||||
var helper = DefaultTemplatesUtilities.GetHtmlHelper(
|
var helper = DefaultTemplatesUtilities.GetHtmlHelper(
|
||||||
model,
|
model,
|
||||||
null,
|
Mock.Of<IUrlHelper>(),
|
||||||
viewEngine.Object,
|
viewEngine.Object,
|
||||||
provider,
|
provider,
|
||||||
innerHelper => new StubbyHtmlHelper(innerHelper));
|
innerHelper => new StubbyHtmlHelper(innerHelper));
|
||||||
|
|
@ -465,7 +464,7 @@ Environment.NewLine;
|
||||||
|
|
||||||
var helper = DefaultTemplatesUtilities.GetHtmlHelper(
|
var helper = DefaultTemplatesUtilities.GetHtmlHelper(
|
||||||
model,
|
model,
|
||||||
null,
|
Mock.Of<IUrlHelper>(),
|
||||||
viewEngine.Object,
|
viewEngine.Object,
|
||||||
provider,
|
provider,
|
||||||
innerHelper => new StubbyHtmlHelper(innerHelper));
|
innerHelper => new StubbyHtmlHelper(innerHelper));
|
||||||
|
|
@ -503,7 +502,7 @@ Environment.NewLine;
|
||||||
|
|
||||||
var helper = DefaultTemplatesUtilities.GetHtmlHelper(
|
var helper = DefaultTemplatesUtilities.GetHtmlHelper(
|
||||||
model,
|
model,
|
||||||
null,
|
Mock.Of<IUrlHelper>(),
|
||||||
viewEngine.Object,
|
viewEngine.Object,
|
||||||
provider,
|
provider,
|
||||||
innerHelper => new StubbyHtmlHelper(innerHelper));
|
innerHelper => new StubbyHtmlHelper(innerHelper));
|
||||||
|
|
@ -542,7 +541,7 @@ Environment.NewLine;
|
||||||
|
|
||||||
var helper = DefaultTemplatesUtilities.GetHtmlHelper(
|
var helper = DefaultTemplatesUtilities.GetHtmlHelper(
|
||||||
model,
|
model,
|
||||||
null,
|
Mock.Of<IUrlHelper>(),
|
||||||
viewEngine.Object,
|
viewEngine.Object,
|
||||||
provider,
|
provider,
|
||||||
innerHelper => new StubbyHtmlHelper(innerHelper));
|
innerHelper => new StubbyHtmlHelper(innerHelper));
|
||||||
|
|
@ -624,7 +623,7 @@ Environment.NewLine;
|
||||||
|
|
||||||
var helper = DefaultTemplatesUtilities.GetHtmlHelper(
|
var helper = DefaultTemplatesUtilities.GetHtmlHelper(
|
||||||
model,
|
model,
|
||||||
null,
|
Mock.Of<IUrlHelper>(),
|
||||||
viewEngine.Object,
|
viewEngine.Object,
|
||||||
provider);
|
provider);
|
||||||
helper.ViewData.TemplateInfo.HtmlFieldPrefix = "FieldPrefix";
|
helper.ViewData.TemplateInfo.HtmlFieldPrefix = "FieldPrefix";
|
||||||
|
|
@ -678,7 +677,7 @@ Environment.NewLine;
|
||||||
|
|
||||||
var helper = DefaultTemplatesUtilities.GetHtmlHelper(
|
var helper = DefaultTemplatesUtilities.GetHtmlHelper(
|
||||||
model,
|
model,
|
||||||
null,
|
Mock.Of<IUrlHelper>(),
|
||||||
viewEngine.Object,
|
viewEngine.Object,
|
||||||
provider);
|
provider);
|
||||||
helper.Html5DateRenderingMode = Html5DateRenderingMode.Rfc3339;
|
helper.Html5DateRenderingMode = Html5DateRenderingMode.Rfc3339;
|
||||||
|
|
@ -737,7 +736,7 @@ Environment.NewLine;
|
||||||
|
|
||||||
var helper = DefaultTemplatesUtilities.GetHtmlHelper(
|
var helper = DefaultTemplatesUtilities.GetHtmlHelper(
|
||||||
model,
|
model,
|
||||||
null,
|
Mock.Of<IUrlHelper>(),
|
||||||
viewEngine.Object,
|
viewEngine.Object,
|
||||||
provider);
|
provider);
|
||||||
|
|
||||||
|
|
@ -929,13 +928,13 @@ Environment.NewLine;
|
||||||
get { return _innerHelper.JavaScriptStringEncoder; }
|
get { return _innerHelper.JavaScriptStringEncoder; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Contextualize([NotNull] ViewContext viewContext)
|
public void Contextualize(ViewContext viewContext)
|
||||||
{
|
{
|
||||||
(_innerHelper as ICanHasViewContext)?.Contextualize(viewContext);
|
(_innerHelper as ICanHasViewContext)?.Contextualize(viewContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IHtmlContent ActionLink(
|
public IHtmlContent ActionLink(
|
||||||
[NotNull] string linkText,
|
string linkText,
|
||||||
string actionName,
|
string actionName,
|
||||||
string controllerName,
|
string controllerName,
|
||||||
string protocol,
|
string protocol,
|
||||||
|
|
@ -1033,7 +1032,7 @@ Environment.NewLine;
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GenerateIdFromName([NotNull] string name)
|
public string GenerateIdFromName(string name)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
@ -1050,7 +1049,7 @@ Environment.NewLine;
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<SelectListItem> GetEnumSelectList([NotNull] Type enumType)
|
public IEnumerable<SelectListItem> GetEnumSelectList(Type enumType)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
@ -1081,7 +1080,7 @@ Environment.NewLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<IHtmlContent> PartialAsync(
|
public Task<IHtmlContent> PartialAsync(
|
||||||
[NotNull] string partialViewName,
|
string partialViewName,
|
||||||
object model,
|
object model,
|
||||||
ViewDataDictionary viewData)
|
ViewDataDictionary viewData)
|
||||||
{
|
{
|
||||||
|
|
@ -1108,13 +1107,13 @@ Environment.NewLine;
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task RenderPartialAsync([NotNull] string partialViewName, object model, ViewDataDictionary viewData)
|
public Task RenderPartialAsync(string partialViewName, object model, ViewDataDictionary viewData)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IHtmlContent RouteLink(
|
public IHtmlContent RouteLink(
|
||||||
[NotNull] string linkText,
|
string linkText,
|
||||||
string routeName,
|
string routeName,
|
||||||
string protocol,
|
string protocol,
|
||||||
string hostName,
|
string hostName,
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,13 @@ using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.AspNet.Antiforgery;
|
using Microsoft.AspNet.Antiforgery;
|
||||||
|
using Microsoft.AspNet.Http.Internal;
|
||||||
|
using Microsoft.AspNet.Mvc.Abstractions;
|
||||||
using Microsoft.AspNet.Mvc.ModelBinding;
|
using Microsoft.AspNet.Mvc.ModelBinding;
|
||||||
using Microsoft.AspNet.Mvc.Rendering;
|
using Microsoft.AspNet.Mvc.Rendering;
|
||||||
using Microsoft.AspNet.Mvc.Routing;
|
using Microsoft.AspNet.Mvc.Routing;
|
||||||
using Microsoft.AspNet.Mvc.ViewEngines;
|
using Microsoft.AspNet.Mvc.ViewEngines;
|
||||||
|
using Microsoft.AspNet.Routing;
|
||||||
using Microsoft.Framework.OptionsModel;
|
using Microsoft.Framework.OptionsModel;
|
||||||
using Microsoft.Framework.WebEncoders;
|
using Microsoft.Framework.WebEncoders;
|
||||||
using Moq;
|
using Moq;
|
||||||
|
|
@ -661,7 +664,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
||||||
// GetCurrentValues uses only the ModelStateDictionary and ViewDataDictionary from the passed ViewContext.
|
// GetCurrentValues uses only the ModelStateDictionary and ViewDataDictionary from the passed ViewContext.
|
||||||
private static ViewContext GetViewContext<TModel>(TModel model, IModelMetadataProvider metadataProvider)
|
private static ViewContext GetViewContext<TModel>(TModel model, IModelMetadataProvider metadataProvider)
|
||||||
{
|
{
|
||||||
var actionContext = new ActionContext();
|
var actionContext = new ActionContext(new DefaultHttpContext(), new RouteData(), new ActionDescriptor());
|
||||||
var viewData = new ViewDataDictionary<TModel>(metadataProvider, actionContext.ModelState)
|
var viewData = new ViewDataDictionary<TModel>(metadataProvider, actionContext.ModelState)
|
||||||
{
|
{
|
||||||
Model = model,
|
Model = model,
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue