public static ColumnAttribute GetColumnAttribute(PropertyInfo propertyInfo) { if (propertyInfo.PropertyType == typeof(DataRow)) { return(null); } ColumnAttribute[] attributes = CustomAttributeProvider.GetAttributes <ColumnAttribute>(propertyInfo); foreach (ColumnAttribute attribute in attributes) { if (attribute.ColumnName == String.Empty) { attribute.ColumnName = propertyInfo.Name; } if (attribute.CType == CType.Auto) { attribute.CType = propertyInfo.PropertyType.ToCType(); } return(attribute); } if (attributes.Length == 0) { Attribute[] non = CustomAttributeProvider.GetAttributes <NonPersistentAttribute>(propertyInfo); if (non.Length > 0) { return(null); } non = CustomAttributeProvider.GetAttributes <AssociationAttribute>(propertyInfo); if (non.Length > 0) { return(null); } //no other attribute defined. if (propertyInfo.CanRead && propertyInfo.CanWrite) { try { return(new ColumnAttribute(propertyInfo.Name, propertyInfo.PropertyType.ToCType())); } catch (Exception) { return(null); //some type is not supported } } } return(null); }
private bool IsColumn1Identity() { ColumnAttribute[] attributes = CustomAttributeProvider.GetAttributes <ColumnAttribute>(propertyInfo1); if (attributes.Length == 0) { return(false); } return(attributes[0].Identity); }
public static AssociationAttribute GetAssociationAttribute(PropertyInfo propertyInfo) { AssociationAttribute[] attributes = CustomAttributeProvider.GetAttributes <AssociationAttribute>(propertyInfo); foreach (AssociationAttribute attribute in attributes) { return(attribute); } return(null); }
public virtual void SaveAssociations() { foreach (PropertyInfo propertyInfo in this.columnProperties) { Attribute[] association = CustomAttributeProvider.GetAttributes <AssociationAttribute>(propertyInfo); if (association.Length != 0) { SaveAssociationCollection(propertyInfo); } } }
public static VAL Class2VAL(object instance, VAL val) { val["ClassName"] = new VAL(instance.GetType().FullName); FieldInfo[] fields = instance.GetType().GetFields(); foreach (FieldInfo fieldInfo in fields) { if (fieldInfo.IsStatic) { continue; } Attribute[] attributes = CustomAttributeProvider.GetAttributes <NonValizedAttribute>(fieldInfo); if (attributes.Length != 0) { continue; } attributes = CustomAttributeProvider.GetAttributes <AssociationAttribute>(fieldInfo); if (attributes.Length != 0) { continue; } val[fieldInfo.Name] = VAL.Boxing(fieldInfo.GetValue(instance)); } PropertyInfo[] properties = instance.GetType().GetProperties(); foreach (PropertyInfo propertyInfo in properties) { ValizableAttribute[] attributes = CustomAttributeProvider.GetAttributes <ValizableAttribute>(propertyInfo); if (attributes.Length != 0 && propertyInfo.CanRead) { val[propertyInfo.Name] = VAL.Boxing(propertyInfo.GetValue(instance, null)); } else { continue; } } return(val); }
public T[] GetAttributes <T>() where T : Attribute { return(CustomAttributeProvider.GetAttributes <T>(this.GetType())); }