Reviving support for IValidatableObject in CoreCLR

This commit is contained in:
Pranav K 2014-04-10 22:03:03 -07:00
parent 0d9c052e43
commit 0f6df5405b
3 changed files with 2 additions and 11 deletions

View File

@ -33,11 +33,9 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
private static Dictionary<Type, DataAnnotationsModelValidationFactory> AttributeFactories =
new Dictionary<Type, DataAnnotationsModelValidationFactory>();
#if NET45
// Factories for IValidatableObject models
private static DataAnnotationsValidatableObjectAdapterFactory DefaultValidatableFactory =
() => new ValidatableObjectAdapter();
#endif
private static Dictionary<Type, DataAnnotationsValidatableObjectAdapterFactory> ValidatableFactories =
new Dictionary<Type, DataAnnotationsValidatableObjectAdapterFactory>();
@ -63,7 +61,6 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
results.Add(factory(attribute));
}
#if NET45
// Produce a validator if the type supports IValidatableObject
if (typeof(IValidatableObject).IsAssignableFrom(metadata.ModelType))
{
@ -74,7 +71,6 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
}
results.Add(factory());
}
#endif
return results;
}

View File

@ -1,5 +1,4 @@
#if NET45
using System;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
@ -56,5 +55,4 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
}
}
}
}
#endif
}

View File

@ -37,8 +37,6 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
}
// Default IValidatableObject adapter factory
#if NET45
[Fact]
public void IValidatableObjectGetsAValidator()
{
@ -53,7 +51,6 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
// Assert
Assert.Single(validators);
}
#endif
// Integration with metadata system