Commit Graph

17 Commits

Author SHA1 Message Date
Ryan Nowak 0832365ec2 Adds ActionContext to OperationBindingContext
This change makes it possible to access the ActionContext/ActionDescriptor
from inside of modelbinding.
2015-11-25 15:17:09 -08:00
Ryan Nowak e2c2676042 Add InputFormatter buffer pooling 2015-11-02 14:36:59 -08:00
Ryan Nowak 8a502dbe5d Rewrite of validation 2015-09-25 16:56:42 -07:00
Doug Bunting 42017faa21 Add `InputFormatterResult` and `InputFormatterContext.ModelName`
- #2722
- make communication of errors from formatters to `BodyModelBinder` explicit
  - `JsonInputFormatter` now adds errors to `ModelStateDictionary` with correct key
- change `InputFormatter.SelectCharacterEncoding()` to add an error and return `null` when it fails
  - one less `Exception` case and removes some duplicate code

nits:
- improve some doc comments (more `<inheritdoc/>`, `<paramref/>` and `<see/>`)
- add another two `BodyValidationIntegrationTests` tests
2015-09-19 21:36:38 -07:00
Ryan Nowak 076ce6a8a1 Make ModelBindingResult a struct. 2015-09-03 12:52:50 -07:00
Ryan Nowak 229724c4ea Reorganize MVC namespaces 2015-09-01 22:28:33 -07:00
Ryan Nowak 98b3f055e1 Change ModelBinding to use a single pass 2015-08-31 11:58:53 -07:00
Ryan Nowak 89a8d0e36c Remove IScopedInstance - use AsyncLocal for ActionContext and
ActionBindingContext

This change replaces IScopedInstance<T> in favor or IActionContextAccessor
and IActionBindingContextAccessor. In the spirit of IHttpContextAccessor,
these are both singletons which use AsyncLocal for storage.

This change allows the invoker factory to be cached which results in some
significant perf gains.
2015-08-13 15:58:29 -07:00
Doug Bunting a170a4e1e4 Add `ModelBindingContext.IsFirstChanceBinding` and `IsTopLevelObject`
- cleanup duplicate code now that #2445 is fixed
- update unit tests using old `ModelBindingContext` setups
- fix (just) one integration test where `MutableObjectModelBinder` incorrectly calculated
  `isTopLevelObject` and returned a non-`null` model
- undo temporary changes in `BodyModelBinderTests` due to increased reliance on incorrect
  `isTopLevelObject` in #2445 fix

nits:
- combine tests that are now duplicates
- beef up coverage of some `MutableObjectModelBinderTest` cases
- remove unused `using`s
2015-06-24 09:17:29 -07:00
Doug Bunting 715a0b6021 Add `ModelState` entries for greedy and type-matching model binders
- part II of II for #2445
- `FormCollectionModelBinder` is an exception because container is not user-provided
 - no `ModelState` entry added
- enable tests that #2445 was blocking
 - fix these and other tests expecting different `ModelState` entries
- simplify logic in `FormFileModelBinder`

`ValueProviderResult`
- remove `protected` setters and parameterless constructor
 - no scenario for their use in subclasses; however `ConvertTo()` remains `virtual`
- add single-parameter constructor
 - use in most of the greedy and type-matching model binders
- add doc comments throughout class

nits:
- use new `ValueProviderResult` constructor in many existing tests
- `""` -> `string.Empty` and `vpr` -> `valueProviderResult` in `ValueProviderResultTest`
- improve some test names in `BodyValidationIntegrationTests`
- do not check `Message` of a Json.NET `Exception`
2015-06-23 22:34:55 -07:00
Doug Bunting c4fa402105 Add `ModelBindingResult.IsFatalError` and make body binding more consistent
- part I of II for #2445 (with a duplicate code PR to follow)
- needed for #2445 because new `ModelState` entries for values will make inconsisteny worse
- change `BodyModelBinder` to use same keys for all `ModelBindingResult`s and `ModelState` entries
 - return fatal error result if formatter adds an error to `ModelState`
 - update potential callers to avoid avoid ignoring `IsFatalError`
- fix test attempting to serialize all of `ModelState`
 - will be borked with additional `RawValue`s in state
- fix two other tests that serialized `ModelState` but checked only `IsValid`

nits:
- address minor inconsistencies in `ModelBindingContext`
- use `System.Reflection.Extensions` package a bit more, where it's already referenced
- remove some unused resources
2015-06-18 16:19:01 -07:00
Harsh Gupta 22f1881cc6 Restoring modelvalidation node. 2015-05-14 18:38:26 -07:00
Ryan Nowak 90805fa827 Pass InputFormatters in OBC
This removes the need to use IScopedInstance<ActionBindingContext> to get
access to the formatters.
2015-05-13 16:02:34 -07:00
Chris R bd03142dab React to Http namespace changes. 2015-05-07 15:19:10 -07:00
N. Taylor Mullen 64e726d2b2 Update LICENSE.txt and license header on files. 2015-05-01 13:55:25 -07:00
Chris Ross 6223aac9be Handle Http.Core rename. 2015-04-16 15:48:27 -07:00
Pranav K 43e24b2aad Removing IInputFormatterSelector
Follow up work item to #2269
2015-04-08 07:35:48 -07:00