public static int Get(MemberInfo mi, int defaultValue) { MaxLengthAttribute customAttribute = (MaxLengthAttribute)Attribute.GetCustomAttribute(mi, typeof(MaxLengthAttribute)); if (customAttribute != null) { return(customAttribute.MaxLength); } return(0); }
public static int ForPropertyDescriptor(PropertyDescriptor pd, double pxOnChar) { DefaultWidthAttribute attribute = (DefaultWidthAttribute)pd.Attributes[typeof(DefaultWidthAttribute)]; if (attribute == null) { return(ForType(pd.PropertyType, pxOnChar)); } MaxLengthAttribute attribute2 = (MaxLengthAttribute)pd.Attributes[typeof(MaxLengthAttribute)]; int num = (attribute2 != null) ? ((int)((attribute2.MaxLength * pxOnChar) * 1.1)) : 0x7fffffff; if (attribute.InChars) { return(Math.Min((int)((attribute.Width * pxOnChar) * 1.1), num)); } return(Math.Min(attribute.Width, num)); }
public static string ForPropertyDescriptor(PropertyDescriptor pd) { DefaultWidthAttribute attribute = (DefaultWidthAttribute)pd.Attributes[typeof(DefaultWidthAttribute)]; if (attribute == null) { return(ForTypeImpl(pd.PropertyType)); } if (!attribute.InChars) { return(attribute.Width + "px"); } int width = attribute.Width; MaxLengthAttribute attribute2 = (MaxLengthAttribute)pd.Attributes[typeof(MaxLengthAttribute)]; if ((attribute2 != null) && (attribute2.MaxLength < width)) { width = attribute2.MaxLength; } return(width.ToString()); }