Пример #1
0
        internal static IModelBinder GetBinderFromAttributes(Type type, Action <Type> errorAction)
        {
            AttributeList allAttrs            = new AttributeList(TypeDescriptorHelper.Get(type).GetAttributes());
            CustomModelBinderAttribute binder = allAttrs.SingleOfTypeDefaultOrError <Attribute, CustomModelBinderAttribute, Type>(errorAction, type);

            return(binder == null ? null : binder.GetBinder());
        }
Пример #2
0
        internal static IModelBinder GetBinderFromAttributes(ICustomAttributeProvider element, Action <ICustomAttributeProvider> errorAction)
        {
            CustomModelBinderAttribute[] attrs = (CustomModelBinderAttribute[])element.GetCustomAttributes(typeof(CustomModelBinderAttribute), true /* inherit */);
            // For compatibility, return null if no attributes.
            if (attrs == null)
            {
                return(null);
            }
            CustomModelBinderAttribute binder = attrs.SingleDefaultOrError(errorAction, element);

            return(binder == null ? null : binder.GetBinder());
        }