/// <summary> /// 从XmlReader中设置属性 /// </summary> /// <param name="reader">Xml阅读器</param> /// <param name="dType">DeclaringType</param> /// <param name="mi">成员属性</param> public void ReadFromXml(XmlReader reader, System.Type dType, MemberInfo mi) { this.memberInfo = mi; this.declaringType = dType; this.propertyName = XmlHelper.GetAttributeValue(reader, "propertyName", this.propertyName); this.dataFieldName = XmlHelper.GetAttributeValue(reader, "dataFieldName", this.dataFieldName); this.format = XmlHelper.GetAttributeValue(reader, "format", this.format); this.isIdentity = XmlHelper.GetAttributeValue(reader, "isIdentity", this.isIdentity); this.primaryKey = XmlHelper.GetAttributeValue(reader, "primaryKey", this.primaryKey); this.length = XmlHelper.GetAttributeValue(reader, "length", this.length); this.isNullable = XmlHelper.GetAttributeValue(reader, "isNullable", this.isNullable); this.bindingFlags = XmlHelper.GetAttributeValue(reader, "bindingFlags", this.bindingFlags); this.defaultExpression = XmlHelper.GetAttributeValue(reader, "defaultExpression", this.defaultExpression); this.enumUsage = XmlHelper.GetAttributeValue(reader, "enumUsage", this.enumUsage); this.subClassPropertyName = XmlHelper.GetAttributeValue(reader, "subClassPropertyName", this.subClassPropertyName); this.subClassTypeDescription = XmlHelper.GetAttributeValue(reader, "subClassTypeDescription", this.subClassTypeDescription); this.encryptProperty = XmlHelper.GetAttributeValue(reader, "encryptProperty", false); this.encryptorName = XmlHelper.GetAttributeValue(reader, "encryptorName", (string)null); }
/// <summary> /// 从对应属性进行填充 /// </summary> internal protected virtual void FillFromAttr(ConditionMappingAttributeBase attr) { if (attr.DataFieldName.IsNotEmpty()) { this.dataFieldName = attr.DataFieldName; } this.enumUsage = attr.EnumUsage; this.prefix = attr.Prefix; this.postfix = attr.Postfix; this.adjustDays = attr.AdjustDays; this.isExpression = attr.IsExpression; this.defaultValueUsage = attr.DefaultValueUsage; this.utcTimeToLocal = attr.UtcTimeToLocal; this.defaultExpression = attr.DefaultExpression; }
/// <summary> /// 从XmlReader中设置属性 /// </summary> /// <param name="reader">Xml阅读器</param> /// <param name="mi">成员属性</param> public void ReadFromXml(XmlReader reader, MemberInfo mi) { this.memberInfo = mi; this.propertyName = XmlHelper.GetAttributeValue(reader, "propertyName", this.propertyName); this.dataFieldName = XmlHelper.GetAttributeValue(reader, "dataFieldName", this.dataFieldName); this.isIdentity = XmlHelper.GetAttributeValue(reader, "isIdentity", this.isIdentity); this.primaryKey = XmlHelper.GetAttributeValue(reader, "primaryKey", this.primaryKey); this.length = XmlHelper.GetAttributeValue(reader, "length", this.length); this.isNullable = XmlHelper.GetAttributeValue(reader, "isNullable", this.isNullable); this.bindingFlags = XmlHelper.GetAttributeValue(reader, "bindingFlags", this.bindingFlags); this.defaultExpression = XmlHelper.GetAttributeValue(reader, "defaultExpression", this.defaultExpression); this.enumUsage = XmlHelper.GetAttributeValue(reader, "enumUsage", this.enumUsage); this.subClassPropertyName = XmlHelper.GetAttributeValue(reader, "subClassPropertyName", this.subClassPropertyName); this.subClassTypeDescription = XmlHelper.GetAttributeValue(reader, "subClassTypeDescription", this.subClassTypeDescription); }
/// <summary> /// 构造方法 /// </summary> /// <param name="usage">如果对应的属性是枚举类型,生成Sql时,是否使用枚举类型的值(整型),否则使用字符串</param> public SqlBehaviorAttribute(EnumUsageTypes usage) { this.enumUsage = usage; }
/// <summary> /// 绑定枚举 /// </summary> /// <param name="enumType">枚举类型</param> /// <param name="enumUsage">枚举使用方式</param> /// <returns></returns> private IList BuildEnumList(System.Type enumType, EnumUsageTypes enumUsage) { IList result = null; EnumItemDescriptionList listEnum = EnumItemDescriptionAttribute.GetDescriptionList(enumType); if (enumUsage == EnumUsageTypes.UseEnumValue) { List<KeyValuePair<int, string>> list = new List<KeyValuePair<int, string>>(); foreach (EnumItemDescription enumItem in listEnum) { KeyValuePair<int, string> kp = new KeyValuePair<int, string>(enumItem.EnumValue, string.IsNullOrEmpty(enumItem.Description) ? enumItem.Name : enumItem.Description); list.Add(kp); } result = list; } else { List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>(); foreach (EnumItemDescription enumItem in listEnum) { KeyValuePair<string, string> kp = new KeyValuePair<string, string>(enumItem.Name, string.IsNullOrEmpty(enumItem.Description) ? enumItem.Name : enumItem.Description); list.Add(kp); } result = list; } return result; }
/// <summary> /// 构造方法 /// </summary> /// <param name="subPropertyName"></param> /// <param name="usage">如果对应的属性是枚举类型,生成Sql时,是否使用枚举类型的值(整型),否则使用字符串</param> public SubClassSqlBehaviorAttribute(string subPropertyName, EnumUsageTypes usage) : base(usage) { this.subPropertyName = subPropertyName; }