Reviving support for IValidatableObject in CoreCLR
This commit is contained in:
parent
0d9c052e43
commit
0f6df5405b
|
|
@ -33,11 +33,9 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
|
||||||
private static Dictionary<Type, DataAnnotationsModelValidationFactory> AttributeFactories =
|
private static Dictionary<Type, DataAnnotationsModelValidationFactory> AttributeFactories =
|
||||||
new Dictionary<Type, DataAnnotationsModelValidationFactory>();
|
new Dictionary<Type, DataAnnotationsModelValidationFactory>();
|
||||||
|
|
||||||
#if NET45
|
|
||||||
// Factories for IValidatableObject models
|
// Factories for IValidatableObject models
|
||||||
private static DataAnnotationsValidatableObjectAdapterFactory DefaultValidatableFactory =
|
private static DataAnnotationsValidatableObjectAdapterFactory DefaultValidatableFactory =
|
||||||
() => new ValidatableObjectAdapter();
|
() => new ValidatableObjectAdapter();
|
||||||
#endif
|
|
||||||
|
|
||||||
private static Dictionary<Type, DataAnnotationsValidatableObjectAdapterFactory> ValidatableFactories =
|
private static Dictionary<Type, DataAnnotationsValidatableObjectAdapterFactory> ValidatableFactories =
|
||||||
new Dictionary<Type, DataAnnotationsValidatableObjectAdapterFactory>();
|
new Dictionary<Type, DataAnnotationsValidatableObjectAdapterFactory>();
|
||||||
|
|
@ -63,7 +61,6 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
|
||||||
results.Add(factory(attribute));
|
results.Add(factory(attribute));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if NET45
|
|
||||||
// Produce a validator if the type supports IValidatableObject
|
// Produce a validator if the type supports IValidatableObject
|
||||||
if (typeof(IValidatableObject).IsAssignableFrom(metadata.ModelType))
|
if (typeof(IValidatableObject).IsAssignableFrom(metadata.ModelType))
|
||||||
{
|
{
|
||||||
|
|
@ -74,7 +71,6 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
|
||||||
}
|
}
|
||||||
results.Add(factory());
|
results.Add(factory());
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
#if NET45
|
using System;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
@ -56,5 +55,4 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
@ -37,8 +37,6 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default IValidatableObject adapter factory
|
// Default IValidatableObject adapter factory
|
||||||
|
|
||||||
#if NET45
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void IValidatableObjectGetsAValidator()
|
public void IValidatableObjectGetsAValidator()
|
||||||
{
|
{
|
||||||
|
|
@ -53,7 +51,6 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Single(validators);
|
Assert.Single(validators);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// Integration with metadata system
|
// Integration with metadata system
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue