예제 #1
0
        public static int Get(MemberInfo mi, int defaultValue)
        {
            MaxLengthAttribute customAttribute = (MaxLengthAttribute)Attribute.GetCustomAttribute(mi, typeof(MaxLengthAttribute));

            if (customAttribute != null)
            {
                return(customAttribute.MaxLength);
            }
            return(0);
        }
예제 #2
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));
        }
예제 #3
0
        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());
        }