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
/
ModelValidationContextBase.cs
59 lines (51 loc) · 2.08 KB
/
ModelValidationContextBase.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
namespace Microsoft.AspNetCore.Mvc.ModelBinding.Validation
{
/// <summary>
/// A common base class for <see cref="ModelValidationContext"/> and <see cref="ClientModelValidationContext"/>.
/// </summary>
public class ModelValidationContextBase
{
/// <summary>
/// Instantiates a new <see cref="ModelValidationContextBase"/>.
/// </summary>
/// <param name="actionContext">The <see cref="ActionContext"/> for this context.</param>
/// <param name="modelMetadata">The <see cref="ModelMetadata"/> for this model.</param>
/// <param name="metadataProvider">The <see cref="IModelMetadataProvider"/> to be used by this context.</param>
public ModelValidationContextBase(
ActionContext actionContext,
ModelMetadata modelMetadata,
IModelMetadataProvider metadataProvider)
{
if (actionContext == null)
{
throw new ArgumentNullException(nameof(actionContext));
}
if (modelMetadata == null)
{
throw new ArgumentNullException(nameof(modelMetadata));
}
if (metadataProvider == null)
{
throw new ArgumentNullException(nameof(metadataProvider));
}
ActionContext = actionContext;
ModelMetadata = modelMetadata;
MetadataProvider = metadataProvider;
}
/// <summary>
/// Gets the <see cref="Mvc.ActionContext"/>.
/// </summary>
public ActionContext ActionContext { get; }
/// <summary>
/// Gets the <see cref="ModelBinding.ModelMetadata"/>.
/// </summary>
public ModelMetadata ModelMetadata { get; }
/// <summary>
/// Gets the <see cref="IModelMetadataProvider"/>.
/// </summary>
public IModelMetadataProvider MetadataProvider { get; }
}
}