public APGenElementMap(Type type) { _properties = new APGenPropertyCollection(); _collectionAttribute = Attribute.GetCustomAttribute(type, typeof(APGenCollectionAttribute)) as APGenCollectionAttribute; PropertyInfo[] props = type.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance); foreach (PropertyInfo prop in props) { APGenPropertyAttribute attr = Attribute.GetCustomAttribute(prop, typeof(APGenPropertyAttribute)) as APGenPropertyAttribute; if (attr == null) { continue; } string name = attr.Name != null ? attr.Name : prop.Name; APValidatorAttribute validatorAttr = Attribute.GetCustomAttribute(prop, typeof(APValidatorAttribute)) as APValidatorAttribute; APValidatorBase validator = validatorAttr != null ? validatorAttr.ValidatorInstance : null; TypeConverterAttribute convertAttr = Attribute.GetCustomAttribute(prop, typeof(TypeConverterAttribute)) as TypeConverterAttribute; TypeConverter converter = convertAttr != null ? (TypeConverter)Activator.CreateInstance(Type.GetType(convertAttr.ConverterTypeName), true) : null; APGenProperty property = new APGenProperty(name, prop.PropertyType, attr.DefaultValue, converter, validator, attr.Options); property.CollectionAttribute = Attribute.GetCustomAttribute(prop, typeof(APGenCollectionAttribute)) as APGenCollectionAttribute; _properties.Add(property); } }
public APGenElementMap(Type type) { _properties = new APGenPropertyCollection(); _collectionAttribute = Attribute.GetCustomAttribute(type, typeof(APGenCollectionAttribute)) as APGenCollectionAttribute; PropertyInfo[] props = type.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance); foreach (PropertyInfo prop in props) { APGenPropertyAttribute attr = Attribute.GetCustomAttribute(prop, typeof(APGenPropertyAttribute)) as APGenPropertyAttribute; if (attr == null) continue; string name = attr.Name != null ? attr.Name : prop.Name; APValidatorAttribute validatorAttr = Attribute.GetCustomAttribute(prop, typeof(APValidatorAttribute)) as APValidatorAttribute; APValidatorBase validator = validatorAttr != null ? validatorAttr.ValidatorInstance : null; TypeConverterAttribute convertAttr = Attribute.GetCustomAttribute(prop, typeof(TypeConverterAttribute)) as TypeConverterAttribute; TypeConverter converter = convertAttr != null ? (TypeConverter)Activator.CreateInstance(Type.GetType(convertAttr.ConverterTypeName), true) : null; APGenProperty property = new APGenProperty(name, prop.PropertyType, attr.DefaultValue, converter, validator, attr.Options); property.CollectionAttribute = Attribute.GetCustomAttribute(prop, typeof(APGenCollectionAttribute)) as APGenCollectionAttribute; _properties.Add(property); } }
static APGenIndex() { nameProp = new APGenProperty( "name", typeof(string), null, APCVHelper.WhiteSpaceTrimStringConverter, APCVHelper.NonEmptyStringValidator, APGenPropertyOptions.IsRequired | APGenPropertyOptions.IsKey ); isDefaultProp = new APGenProperty("isDefault", typeof(bool), false); ordersProp = new APGenProperty("", typeof(APGenOrderCollection), null, null, null, APGenPropertyOptions.IsDefaultCollection); properties = new APGenPropertyCollection(); properties.Add(nameProp); properties.Add(isDefaultProp); properties.Add(ordersProp); }
static APGenAlias() { nameProp = new APGenProperty( "name", typeof(string), null, APCVHelper.WhiteSpaceTrimStringConverter, APCVHelper.NonEmptyStringValidator, APGenPropertyOptions.IsRequired | APGenPropertyOptions.IsKey ); properties = new APGenPropertyCollection(); properties.Add(nameProp); }
static APGenOrder() { nameProp = new APGenProperty( "name", typeof(string), null, APCVHelper.WhiteSpaceTrimStringConverter, APCVHelper.NonEmptyStringValidator, APGenPropertyOptions.IsRequired | APGenPropertyOptions.IsKey ); accordingProp = new APGenProperty( "according", typeof(APSqlOrderAccording), APSqlOrderAccording.Asc, new GenericEnumAPConverter(typeof(APSqlOrderAccording)), APCVHelper.DefaultValidator, APGenPropertyOptions.None ); properties = new APGenPropertyCollection(); properties.Add(nameProp); properties.Add(accordingProp); }
internal APGenPropertyCollection GetKeyProperties() { if (_keyProps != null) return _keyProps; APGenPropertyCollection tmpkeyProps = new APGenPropertyCollection(); foreach (APGenProperty prop in Properties) { if (prop.IsKey) tmpkeyProps.Add(prop); } return _keyProps = tmpkeyProps; }
static APGenRelation() { nameProp = new APGenProperty( "name", typeof(string), null, APCVHelper.WhiteSpaceTrimStringConverter, APCVHelper.NonEmptyStringValidator, APGenPropertyOptions.IsRequired | APGenPropertyOptions.IsKey ); masterTableProp = new APGenProperty( "masterTable", typeof(string), "", TypeDescriptor.GetConverter(typeof(string)), APCVHelper.NonEmptyStringValidator, APGenPropertyOptions.IsRequired ); masterColumnProp = new APGenProperty( "masterColumn", typeof(string), "", TypeDescriptor.GetConverter(typeof(string)), APCVHelper.NonEmptyStringValidator, APGenPropertyOptions.IsRequired ); slaveTableProp = new APGenProperty( "slaveTable", typeof(string), "", TypeDescriptor.GetConverter(typeof(string)), APCVHelper.NonEmptyStringValidator, APGenPropertyOptions.IsRequired ); slaveColumnProp = new APGenProperty( "slaveColumn", typeof(string), "", TypeDescriptor.GetConverter(typeof(string)), APCVHelper.NonEmptyStringValidator, APGenPropertyOptions.IsRequired ); cascadeTypeProp = new APGenProperty( "cascadeType", typeof(APRelationCascadeType), APRelationCascadeType.None, new GenericEnumAPConverter(typeof(APRelationCascadeType)), APCVHelper.DefaultValidator, APGenPropertyOptions.None ); commentProp = new APGenProperty("comment", typeof(string)); properties = new APGenPropertyCollection(); properties.Add(nameProp); properties.Add(masterTableProp); properties.Add(masterColumnProp); properties.Add(slaveTableProp); properties.Add(slaveColumnProp); properties.Add(cascadeTypeProp); properties.Add(commentProp); }
static APGenColumn() { nameProp = new APGenProperty( "name", typeof(string), null, APCVHelper.WhiteSpaceTrimStringConverter, APCVHelper.NonEmptyStringValidator, APGenPropertyOptions.IsRequired | APGenPropertyOptions.IsKey ); columnNameProp = new APGenProperty("columnName", typeof(string)); propertyNameProp = new APGenProperty("propertyName", typeof(string)); typeProp = new APGenProperty( "type", typeof(string), "string", TypeDescriptor.GetConverter(typeof(string)), APCVHelper.NonEmptyStringValidator, APGenPropertyOptions.None ); isEnumProp = new APGenProperty("isEnum", typeof(bool), false); defaultValueProp = new APGenProperty("defaultValue", typeof(string), ""); overrideProp = new APGenProperty("override", typeof(bool), false); identityTypeProp = new APGenProperty( "identityType", typeof(APColumnIdentityType), APColumnIdentityType.None, new GenericEnumAPConverter(typeof(APColumnIdentityType)), APCVHelper.DefaultValidator, APGenPropertyOptions.None ); providerIdentityBaseProp = new APGenProperty("providerIdentityBase", typeof(int), 5000); isNullableProp = new APGenProperty("isNullable", typeof(bool), false); primaryKeyProp = new APGenProperty("primaryKey", typeof(bool), false); dbTypeProp = new APGenProperty( "dbType", typeof(DbType), DbType.Object, new GenericEnumAPConverter(typeof(DbType)), APCVHelper.DefaultValidator, APGenPropertyOptions.None ); dbDefaultValueProp = new APGenProperty("dbDefaultValue", typeof(string)); dataLengthProp = new APGenProperty("dataLength", typeof(int), 0); precisionProp = new APGenProperty("precision", typeof(int), 18); scaleProp = new APGenProperty("scale", typeof(int), 0); commentProp = new APGenProperty("comment", typeof(string)); displayProp = new APGenProperty("display", typeof(string)); requiredProp = new APGenProperty("required", typeof(bool)); properties = new APGenPropertyCollection(); properties.Add(nameProp); properties.Add(columnNameProp); properties.Add(propertyNameProp); properties.Add(typeProp); properties.Add(isEnumProp); properties.Add(defaultValueProp); properties.Add(overrideProp); properties.Add(identityTypeProp); properties.Add(providerIdentityBaseProp); properties.Add(isNullableProp); properties.Add(primaryKeyProp); properties.Add(dbTypeProp); properties.Add(dbDefaultValueProp); properties.Add(dataLengthProp); properties.Add(precisionProp); properties.Add(scaleProp); properties.Add(commentProp); properties.Add(displayProp); properties.Add(requiredProp); }
static APGenTable() { nameProp = new APGenProperty( "name", typeof(string), null, APCVHelper.WhiteSpaceTrimStringConverter, APCVHelper.NonEmptyStringValidator, APGenPropertyOptions.IsRequired | APGenPropertyOptions.IsKey ); tableNameProp = new APGenProperty("tableName", typeof(string)); classNameProp = new APGenProperty("className", typeof(string)); dataInheritFromBaseProp = new APGenProperty("dataInheritFromBase", typeof(bool), true); dalInheritFromBaseProp = new APGenProperty("dalInheritFromBase", typeof(bool), true); bplInheritFromBaseProp = new APGenProperty("bplInheritFromBase", typeof(bool), true); inheritsProp = new APGenProperty("inherits", typeof(string), ""); commentProp = new APGenProperty("comment", typeof(string)); columnsProp = new APGenProperty("columns", typeof(APGenColumnCollection)); indexesProp = new APGenProperty("indexes", typeof(APGenIndexCollection)); uniquesProp = new APGenProperty("uniques", typeof(APGenIndexCollection)); aliasesProp = new APGenProperty("aliases", typeof(APGenAliasCollection)); properties = new APGenPropertyCollection(); properties.Add(nameProp); properties.Add(tableNameProp); properties.Add(classNameProp); properties.Add(dataInheritFromBaseProp); properties.Add(dalInheritFromBaseProp); properties.Add(bplInheritFromBaseProp); properties.Add(inheritsProp); properties.Add(commentProp); properties.Add(columnsProp); properties.Add(indexesProp); properties.Add(uniquesProp); properties.Add(aliasesProp); }