Exemplo n.º 1
0
        string GetAttributesCode(DynamicModelPropertyInfo property)
        {
            var attributes = property.GetCustomAttributes(false).OfType <Attribute>().ToList();

            if (property.PropertyType == typeof(string) && !attributes.OfType <LocalizableAttribute>().Any())
            {
                attributes.Add(new LocalizableAttribute(true));
            }
            IEnumerable <string> codeList = attributes.Select(attribute => GetAttributeCode(attribute, property)).Where(attributeCode => !string.IsNullOrEmpty(attributeCode));

            return(codeList.Aggregate <string, string>(null, (current, attributeCode) => current + string.Format("   [{0}]{1}", attributeCode, Environment.NewLine)));
        }
Exemplo n.º 2
0
        string GetPropertyTypeCode(DynamicModelPropertyInfo property, string prefix = null)
        {
            if (property.GetCustomAttributes(typeof(NullValueAttribute), false).Any())
            {
                return(TypeToString(property.PropertyType));
            }
            if (!property.PropertyType.BehaveLikeValueType())
            {
                if (_createdInterfaces.ContainsKey(property.PropertyType))
                {
                    return(_createdInterfaces[property.PropertyType]);
                }
                return(GetInterfaceName(_assemblyName, property.PropertyType, prefix));
            }
            Type propertyType = property.PropertyType;

            if (propertyType != typeof(string) && !propertyType.IsStruct())
            {
                propertyType = typeof(Nullable <>).MakeNullAble(property.PropertyType);
            }
            return(TypeToString(propertyType));
        }
Exemplo n.º 3
0
 public static bool FilterAttributes(this DynamicModelPropertyInfo info, Type[] attributes)
 {
     return(attributes.SelectMany(type => info.GetCustomAttributes(type, false)).Any());
 }