Commit Graph

28 Commits

Author SHA1 Message Date
Harsh Gupta ac908d405e Removing ModelMetadataProvider.GetModelMetadataForParameters 2015-03-19 16:42:54 -07:00
N. Taylor Mullen e829ba7646 Update aspnet50/aspnetcore50 => dnx451/dnxcore50. 2015-03-08 12:52:24 -07:00
Ryan Nowak 90cef3b9ca Refactor of the model metadata provider
Separates the MMP into two phases:
1). Creation of the ModelMetadata, discovery of properties and attributes
(reflection) is part of the MMP
2). Lookup of details based on attributes is now part of another phase,
and has its results cached.

Users can now implements and register an IFooMetadataProvider to customize
a single aspect of metadata (see how data annotations does it).
2015-03-05 13:19:10 -08:00
Ryan Nowak 9d5364cf9b Removing ModelMetadata.Model 2015-02-23 19:56:59 -08:00
Harsh Gupta f19c2e493d Merging Model Validation for body and non body validation.
This also fixes #1503.

Currently all model binders except mutable object binder are independent of validation code. The mutable object binder which needs to do some validation ( for scenarios involving [BindRequired] and [BindNever]).
We would be going with an approach where required validaiton happens in input formatters and model binders.
This is needed as validation for value types can best be done at creation time.

Followup PRs:
Introduce support for skipping validation (and not binding) for a particular property/type etc.
2015-02-17 11:50:39 -08:00
Stephen Halter 5de210f527 Fix for #1416 - Remove all uses of ITypeActivator and use the static method instead
- ITypeActivator is being removed
- Where an ITypeActivator was used before, use the static ActivatorUtilities
2015-02-16 16:02:39 -08:00
Ryan Nowak 12f8f23ccb Make BindingSource extensible
This is a major refactor of how IBinderMetadata interacts with model
binders and value providers. We're doing this to support better
extensibility for metadata in ApiExplorer.

You'll notice a bunch of deleted code in DefaultApiDescriptionProvider
that maps metadata marker interfaces to a fixed list of Api sources. This
is replaced now with IBindingSourceMetadata - which also replaces the
hierarchy of marker interfaces. Now user code can create an arbitrary
binding source and have a consistent API for model-binders,
value-providers and full-visibility in ApiExplorer as
well.

Additonally, there's some error checking in place that better enforces the
constraints we already have in the system. IE you can't create a 'greedy'
model binder that uses value-provider data.

Two additional enhancements are planned for followup PRs:
1. Add a BindingSource property to model-metadata. This will remove some
duplication, but I want to delay it because it would touch another 10 or
so files.

2. Add an extensibility interface for our 'special' model binders like the
file binder so these can show up in ApiExplorer as well.
2015-02-05 13:41:31 -08:00
Ryan Nowak 51e7812e7e Fix for #1722 - FromHeader does not respect default value
This change adds support for our three-valued logic to the default value
handling part of the MutableObjectModelBinder.

The issue is that we want to look up a default value when a 'greedy' model
binder returns true but doesn't find a value.

We also don't want to call the property setter unless there is:
1). A value from model binding OR
2). A default value
2015-01-16 17:59:00 -08:00
Chris Ross 9aff289dfe Handle PipelineCore rename. 2015-01-15 15:25:17 -08:00
Ryan Nowak 5ac5c53c09 Adding Resource Filters
This is a new filter stage that surrounds the existing model binding,
action, and result parts of the pipeline. Resource Filters run after
Authorization Filters.

The other major change is to support one of the primary scenarios for
Resource Filters. We want a filter to be able to modify the inputs the
model binding (formatters, model binders, value providers, etc) -- this
means that those changes need to be held on a context object and preserved
so that they can be used in the controller.

So, IActionBindingContextProvider is removed - the ActionBindingContext
will be created by the invoker. For now it will be part of the action
context.
2015-01-12 14:18:20 -08:00
Harsh Gupta d7094fd32d Adding Support for TryUpdateModel using include expressions and predicate. 2014-12-05 17:28:43 -08:00
Harsh Gupta b54c326ee6 Updating Associated Metadata Provider to follow the existing pattern. 2014-11-26 16:56:32 -08:00
Harsh Gupta d00c7ef597 Adding support for property level binding using IBinderMetadata and enabling FromXXX attributes to be decorated on properties. 2014-11-24 21:33:02 -08:00
Pranav K 0e4ec38efe Replacing Assert.Equal(null, Assert.Equal(true \ false etc with
appropriate Xunit equivalents
2014-11-21 08:28:55 -08:00
Doug Bunting 5e067cdb9e Delete trailing whitespace
- #EngineeringDay
- Total replaced: 660  Matching files: 270 in *.cs
- Total replaced: 250  Matching files: 32 in all other files
- Total replaced: 22  Matching files: 8 in a few stragglers

Did not change files under following directories
- test\Microsoft.AspNet.Mvc.Razor.Host.Test\TestFiles\Output
- test\Microsoft.AspNet.Mvc.FunctionalTests\compiler\resources
- test\WebSites\TagHelpersWebSite
(Razor generates trailing whitespace in a case or two)
2014-11-20 16:18:09 -08:00
Ryan Nowak 61f218c8e4 Renaming IBinderMarker and friends to some more descriptive names. 2014-10-17 20:32:03 -07:00
Ryan Nowak df8f84b772 Fix #1287 - Port WebAPI parameter binding behavior
This change modifies the default parameter binding behavior for an
ApiController to use the WebAPI rules.

'simple types' default to use route data or query string
'complex types' default to use the body (formatters)

Adds ModelBindingAttribute to enabled model binding
2014-10-17 16:51:48 -07:00
Harsh Gupta 75405e3b76 Adding support for bind attribute. 2014-10-17 16:24:28 -07:00
Pranav K 3cd5c17da7 Updating ModelBinding tests to work in Mono 2014-09-30 20:16:21 -07:00
David Fowler 34add2249e Updated to use the new target framework in project.json 2014-09-04 02:02:40 -07:00
Pranav K d604c18368 Moving IModelValidatorProvider to Options
Fixes #879
2014-08-26 11:53:32 -07:00
Andrew Peters f13865dedc Updating copyright headers 2014-05-08 23:01:20 -07:00
Pranav K 4566947e33 Change ModelState.IsValid back to bool 2014-05-07 17:41:47 -07:00
anpete 8208cd6b2f Update file headers 2014-05-01 17:42:33 -07:00
Pranav K b0c7dc9220 Make IModelBinder and IValueProvider methods async 2014-04-24 15:16:27 -07:00
Pranav K c72c80c101 Add the ability to correctly determine if a particular field has been validated.
There are several portions of model validation that attempt to avoid
revalidating if a field has been validated. However the behavior of
ModelStateDictionary makes it difficult to distinguish between an
unvalidated field and a field without validation errors. This change
resolves this issue by letting the caller distinguish between the two
cases.
2014-03-31 12:40:38 -07:00
Pranav K af7d61113b Updating test projects to use Microsoft.AspNet.Testing 2014-03-25 15:10:58 -07:00
Pranav K f8dd52dfe3 Reintroducing BindingBehaviorAttribute attribute
* Porting MutableObjectModelBinder tests
* Fix issues in MutableObjectModelBinder introduced by changing from
  TypeDescriptors to reflection
2014-03-19 16:52:02 -07:00