/// <summary> /// 获取集合类型的数据字段 /// </summary> /// <param name="propertyName"></param> /// <param name="propertyType"></param> /// <returns></returns> private bool TryGetListField(PropertyRepositoryAttribute attribute, bool isSnapshot, ref IDataField result) { var elementType = attribute.GetElementType(); if (DomainObject.IsValueObject(elementType)) { //值对象 var field = new ValueObjectListField(attribute); //当值对象A引用了值对象A时,会造成死循环 //var mapper = DataMapperFactory.Create(elementType); //var childs = mapper.GetObjectFields(elementType, isSnapshot); //field.AddChilds(childs); result = field; return(true); } else if (DomainObject.IsAggregateRoot(elementType)) { //引用了根对象 var field = new AggregateRootListField(attribute); result = field; return(true); } else if (DomainObject.IsEntityObject(elementType)) { //引用了内部实体对象 var field = new EntityObjectListField(attribute); //当成员对象A引用了成员对象A时,会造成死循环 //var mapper = DataMapperFactory.Create(elementType); //var childs = mapper.GetObjectFields(elementType, isSnapshot); //field.AddChilds(childs); result = field; return(true); } else if (elementType.IsList()) { throw new DomainDesignException(Strings.NestedCollection); } else { //值集合 var field = new ValueListField(attribute); result = field; return(true); } }
/// <summary> /// 获取集合类型的数据字段 /// </summary> /// <param name="propertyName"></param> /// <param name="propertyType"></param> /// <returns></returns> private static bool TryGetListField(PropertyRepositoryAttribute attribute, bool isSnapshot, ref IDataField result) { var elementType = attribute.PropertyType.ResolveElementType(); if (DomainObject.IsValueObject(elementType)) { //值对象 var field = new ValueObjectListField(attribute); var childs = GetObjectFields(elementType, isSnapshot); field.AddChilds(childs); result = field; return(true); } else if (DomainObject.IsAggregateRoot(elementType)) { //引用了根对象 var field = new AggregateRootListField(attribute); result = field; return(true); } else if (DomainObject.IsEntityObject(elementType)) { //引用了内部实体对象 var field = new EntityObjectListField(attribute); var childs = GetObjectFields(elementType, isSnapshot); field.AddChilds(childs); result = field; return(true); } else if (IsList(elementType)) { throw new DomainDesignException(Strings.NestedCollection); } else { //值集合 var field = new ValueListField(attribute); result = field; return(true); } }