linux-packaging-mono/mcs/class/System.Web.Mvc3/Mvc/ModelMetadataProviders.cs
Jo Shields a575963da9 Imported Upstream version 3.6.0
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
2014-08-13 10:39:27 +01:00

33 lines
1.1 KiB
C#

namespace System.Web.Mvc {
public class ModelMetadataProviders {
private ModelMetadataProvider _currentProvider;
private static ModelMetadataProviders _instance = new ModelMetadataProviders();
private IResolver<ModelMetadataProvider> _resolver;
internal ModelMetadataProviders(IResolver<ModelMetadataProvider> resolver = null) {
_resolver = resolver ?? new SingleServiceResolver<ModelMetadataProvider>(
() => _currentProvider,
new DataAnnotationsModelMetadataProvider(),
"ModelMetadataProviders.Current"
);
}
public static ModelMetadataProvider Current {
get {
return _instance.CurrentInternal;
}
set {
_instance.CurrentInternal = value;
}
}
internal ModelMetadataProvider CurrentInternal {
get {
return _resolver.Current;
}
set {
_currentProvider = value ?? new EmptyModelMetadataProvider();
}
}
}
}