internal EntityTreeMetadata(EntityTreeMappingAttribute attribute) { this.attribute = attribute; if (attribute.SignStyle == SignStyle.Variable && attribute.SignBits != null) { lengthBits = new int[attribute.SignBits.Length]; var total = attribute.SignBits[0]; lengthBits[0] = total; for (var i = 1; i < attribute.SignBits.Length; i++) { total += attribute.SignBits[i]; lengthBits[i] = total; } } }
/// <summary> /// 使用实体类型和 <see cref="EntityTreeMappingAttribute"/> 对象创建一个 <see cref="EntityTreeMetadata"/> 对象。 /// </summary> /// <param name="attribute"></param> /// <param name="entityType"></param> /// <returns></returns> public static EntityTreeMetadata CreateMetadata(Type entityType, EntityTreeMappingAttribute attribute) { var metadata = new EntityTreeMetadata(attribute); IProperty property; if (!string.IsNullOrEmpty(attribute.InnerSign) && (property = PropertyUnity.GetProperty(entityType, attribute.InnerSign)) != null) { metadata.InnerSign = property; } if (!string.IsNullOrEmpty(attribute.Level) && (property = PropertyUnity.GetProperty(entityType, attribute.Level)) != null) { metadata.Level = property; } if (!string.IsNullOrEmpty(attribute.Order) && (property = PropertyUnity.GetProperty(entityType, attribute.Order)) != null) { metadata.Order = property; } if (!string.IsNullOrEmpty(attribute.Name) && (property = PropertyUnity.GetProperty(entityType, attribute.Name)) != null) { metadata.Name = property; } if (!string.IsNullOrEmpty(attribute.FullName) && (property = PropertyUnity.GetProperty(entityType, attribute.FullName)) != null) { metadata.FullName = property; } return(metadata); }