Replacing not null checks in ModelBinding with NotNullAttribute : part deux
This commit is contained in:
parent
6fb0d5b282
commit
12632c5fc3
|
|
@ -13,25 +13,15 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Internal
|
|||
private readonly ICollection<string> _originalValues;
|
||||
private readonly string[] _sortedValues;
|
||||
|
||||
internal PrefixContainer(ICollection<string> values)
|
||||
internal PrefixContainer([NotNull] ICollection<string> values)
|
||||
{
|
||||
if (values == null)
|
||||
{
|
||||
throw new ArgumentNullException("values");
|
||||
}
|
||||
|
||||
_originalValues = values;
|
||||
_sortedValues = _originalValues.ToArrayWithoutNulls();
|
||||
Array.Sort(_sortedValues, StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
internal bool ContainsPrefix(string prefix)
|
||||
internal bool ContainsPrefix([NotNull] string prefix)
|
||||
{
|
||||
if (prefix == null)
|
||||
{
|
||||
throw new ArgumentNullException("prefix");
|
||||
}
|
||||
|
||||
if (prefix.Length == 0)
|
||||
{
|
||||
return _sortedValues.Length > 0; // only match empty string when we have some value
|
||||
|
|
|
|||
|
|
@ -6,13 +6,8 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
|
|||
{
|
||||
public abstract class AssociatedValidatorProvider : IModelValidatorProvider
|
||||
{
|
||||
public IEnumerable<IModelValidator> GetValidators(ModelMetadata metadata)
|
||||
public IEnumerable<IModelValidator> GetValidators([NotNull] ModelMetadata metadata)
|
||||
{
|
||||
if (metadata == null)
|
||||
{
|
||||
throw new ArgumentNullException("metadata");
|
||||
}
|
||||
|
||||
if (metadata.ContainerType != null && !string.IsNullOrEmpty(metadata.PropertyName))
|
||||
{
|
||||
return GetValidatorsForProperty(metadata);
|
||||
|
|
|
|||
|
|
@ -7,13 +7,8 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
|
|||
{
|
||||
public class DataAnnotationsModelValidator : IModelValidator
|
||||
{
|
||||
public DataAnnotationsModelValidator(ValidationAttribute attribute)
|
||||
public DataAnnotationsModelValidator([NotNull] ValidationAttribute attribute)
|
||||
{
|
||||
if (attribute == null)
|
||||
{
|
||||
throw new ArgumentNullException("attribute");
|
||||
}
|
||||
|
||||
Attribute = attribute;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue