protected virtual ICustomTypeDescriptor GetTypeDescriptor(BindingContext context)
        {
            AssociatedMetadataTypeTypeDescriptionProvider provider =
                new AssociatedMetadataTypeTypeDescriptionProvider(context.ModelType);

            return provider.GetTypeDescriptor(context.ModelType, context.Model);
        }
		public void GetTypeDescriptor ()
		{
			var v = new AssociatedMetadataTypeTypeDescriptionProvider (typeof (string));

			Assert.IsTrue (v != null, "#A1");

			string s = "test";
			var o = v.GetTypeDescriptor (s.GetType (), s);
			Assert.IsTrue (o != null, "#B1");

			Type oType = o.GetType ();
			Assert.AreEqual ("System.ComponentModel.DataAnnotations.AssociatedMetadataTypeTypeDescriptor", oType.ToString (), "#C1");
			Assert.IsTrue (typeof (ICustomTypeDescriptor).IsAssignableFrom (oType), "#C2");
			Assert.IsTrue (typeof (CustomTypeDescriptor).IsAssignableFrom (oType), "#C3");
		}
예제 #3
0
		static ICustomTypeDescriptor GetTypeDescriptor(object model, Type modelType) 
        {
            var provider = new AssociatedMetadataTypeTypeDescriptionProvider(modelType);
            return provider.GetTypeDescriptor(modelType, model);
        }