This repository has been archived by the owner on Dec 14, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding support for model binding specifically marked controller prope…
…rties.
- Loading branch information
1 parent
c082d4a
commit adeb1ba
Showing
42 changed files
with
958 additions
and
280 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
src/Microsoft.AspNet.Mvc.Core/ApplicationModels/PropertyModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Reflection; | ||
using Microsoft.AspNet.Mvc.ModelBinding; | ||
using Microsoft.Framework.Internal; | ||
|
||
namespace Microsoft.AspNet.Mvc.ApplicationModels | ||
{ | ||
/// <summary> | ||
/// A type which is used to represent a property in a <see cref="ControllerModel"/>. | ||
/// </summary> | ||
[DebuggerDisplay("PropertyModel: Name={PropertyName}")] | ||
public class PropertyModel | ||
{ | ||
/// <summary> | ||
/// Creates a new instance of <see cref="PropertyModel"/>. | ||
/// </summary> | ||
/// <param name="propertyInfo">The <see cref="PropertyInfo"/> for the underlying property.</param> | ||
/// <param name="attributes">Any attributes which are annotated on the property.</param> | ||
public PropertyModel([NotNull] PropertyInfo propertyInfo, | ||
[NotNull] IReadOnlyList<object> attributes) | ||
{ | ||
PropertyInfo = propertyInfo; | ||
|
||
Attributes = new List<object>(attributes); | ||
} | ||
|
||
/// <summary> | ||
/// Creats a new instance of <see cref="PropertyModel"/> from a given <see cref="PropertyModel"/>. | ||
/// </summary> | ||
/// <param name="other">The <see cref="PropertyModel"/> which needs to be copied.</param> | ||
public PropertyModel([NotNull] PropertyModel other) | ||
{ | ||
Controller = other.Controller; | ||
Attributes = new List<object>(other.Attributes); | ||
BindingInfo = other.BindingInfo; | ||
PropertyInfo = other.PropertyInfo; | ||
PropertyName = other.PropertyName; | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the <see cref="ControllerModel"/> this <see cref="PropertyModel"/> is associated with. | ||
/// </summary> | ||
public ControllerModel Controller { get; set; } | ||
|
||
/// <summary> | ||
/// Gets any attributes which are annotated on the property. | ||
/// </summary> | ||
public IReadOnlyList<object> Attributes { get; } | ||
|
||
/// <summary> | ||
/// Gets or sets the <see cref="BindingInfo"/> associated with this model. | ||
/// </summary> | ||
public BindingInfo BindingInfo { get; set; } | ||
|
||
/// <summary> | ||
/// Gets the underlying <see cref="PropertyInfo"/>. | ||
/// </summary> | ||
public PropertyInfo PropertyInfo { get; } | ||
|
||
/// <summary> | ||
/// Gets or sets the name of the property represented by this model. | ||
/// </summary> | ||
public string PropertyName { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.