@@ -13,6 +13,18 @@ namespace System.Web.Http.Validation
13
13
/// </summary>
14
14
public class BodyModelValidatorContext
15
15
{
16
+ public BodyModelValidatorContext ( ModelStateDictionary modelState )
17
+ {
18
+ if ( modelState == null )
19
+ {
20
+ throw new ArgumentNullException ( "modelState" ) ;
21
+ }
22
+
23
+ KeyBuilders = new Stack < IBodyModelValidatorKeyBuilder > ( ) ;
24
+ ModelState = modelState ;
25
+ Visited = new HashSet < object > ( ReferenceEqualityComparer . Instance ) ;
26
+ }
27
+
16
28
/// <summary>
17
29
/// Gets or sets the <see cref="ModelMetadataProvider"/> used to provide the model metadata.
18
30
/// </summary>
@@ -29,21 +41,21 @@ public class BodyModelValidatorContext
29
41
public IModelValidatorCache ValidatorCache { get ; set ; }
30
42
31
43
/// <summary>
32
- /// Gets or sets the current <see cref="ModelStateDictionary"/>.
44
+ /// Gets the current <see cref="ModelStateDictionary"/>.
33
45
/// </summary>
34
- public ModelStateDictionary ModelState { get ; set ; }
46
+ public ModelStateDictionary ModelState { get ; private set ; }
35
47
36
48
/// <summary>
37
- /// Gets or sets the set of model objects visited in this validation. Includes the model being validated in the
49
+ /// Gets the set of model objects visited in this validation. Includes the model being validated in the
38
50
/// current scope.
39
51
/// </summary>
40
- public HashSet < object > Visited { get ; set ; }
52
+ public HashSet < object > Visited { get ; private set ; }
41
53
42
54
/// <summary>
43
- /// Gets or sets the stack of <see cref="IBodyModelValidatorKeyBuilder"/>s used in this validation. Includes
55
+ /// Gets the stack of <see cref="IBodyModelValidatorKeyBuilder"/>s used in this validation. Includes
44
56
/// the <see cref="IBodyModelValidatorKeyBuilder"/> to generate model state keys for the current scope.
45
57
/// </summary>
46
- public Stack < IBodyModelValidatorKeyBuilder > KeyBuilders { get ; set ; }
58
+ public Stack < IBodyModelValidatorKeyBuilder > KeyBuilders { get ; private set ; }
47
59
48
60
/// <summary>
49
61
/// Gets or sets the model state prefix for the root scope of this validation.
0 commit comments