@@ -13,6 +13,18 @@ namespace System.Web.Http.Validation
1313 /// </summary>
1414 public class BodyModelValidatorContext
1515 {
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+
1628 /// <summary>
1729 /// Gets or sets the <see cref="ModelMetadataProvider"/> used to provide the model metadata.
1830 /// </summary>
@@ -29,21 +41,21 @@ public class BodyModelValidatorContext
2941 public IModelValidatorCache ValidatorCache { get ; set ; }
3042
3143 /// <summary>
32- /// Gets or sets the current <see cref="ModelStateDictionary"/>.
44+ /// Gets the current <see cref="ModelStateDictionary"/>.
3345 /// </summary>
34- public ModelStateDictionary ModelState { get ; set ; }
46+ public ModelStateDictionary ModelState { get ; private set ; }
3547
3648 /// <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
3850 /// current scope.
3951 /// </summary>
40- public HashSet < object > Visited { get ; set ; }
52+ public HashSet < object > Visited { get ; private set ; }
4153
4254 /// <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
4456 /// the <see cref="IBodyModelValidatorKeyBuilder"/> to generate model state keys for the current scope.
4557 /// </summary>
46- public Stack < IBodyModelValidatorKeyBuilder > KeyBuilders { get ; set ; }
58+ public Stack < IBodyModelValidatorKeyBuilder > KeyBuilders { get ; private set ; }
4759
4860 /// <summary>
4961 /// Gets or sets the model state prefix for the root scope of this validation.
0 commit comments