public override ModelMetadata GetMetadataForType(Func <object> modelAccessor, Type modelType)
        {
            Check.Requires <ArgumentNullException>(modelType != null);

            ICollection <Attribute> a = new List <Attribute>();

            //GetPropertyDescriptors(modelType).ToList().ForEach(x => a.Union(x.Attributes.Cast<Attribute>()));

            var typeAttributes = TypeDescriptorHelper.Get(modelType).GetAttributes();

            for (var i = 0; i < typeAttributes.Count; i++)
            {
                a.Add(typeAttributes[i]);
            }

            ModelMetadata result = CreateMetadata(a, null /* containerType */, modelAccessor, modelType, null /* propertyName */);

            return(result);
        }
示例#2
0
 protected virtual ICustomTypeDescriptor GetTypeDescriptor(Type type)
 {
     return(TypeDescriptorHelper.Get(type));
 }
 protected virtual IEnumerable <PropertyDescriptor> GetPropertyDescriptors(Type type)
 {
     return(TypeDescriptorHelper.GetPropertyDescriptors(type));
 }