Beispiel #1
0
        /// <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);
            }
        }
 private void InitObjectType(Type objectType, PropertyRepositoryAttribute tip)
 {
     this.ObjectType = objectType;
     if (this.Type == DataTableType.Middle)
     {
         this.ElementType = tip.GetElementType();
     }
     else if (this.Type == DataTableType.AggregateRoot)
     {
         this.ObjectTip = ObjectRepositoryAttribute.GetTip(this.ObjectType, true);
     }
     else
     {
         //对于值对象和引用对象,如果没有定义ObjectRepositoryAttribute,那么使用根的ObjectRepositoryAttribute
         this.ObjectTip = ObjectRepositoryAttribute.GetTip(this.ObjectType, false);
         if (this.ObjectTip == null)
         {
             this.ObjectTip = this.Root.ObjectTip;
         }
     }
 }
 public ValueListField(PropertyRepositoryAttribute attribute)
     : base(attribute)
 {
     this.ValueType = attribute.GetElementType();
 }