コード例 #1
0
ファイル: EOMReader.cs プロジェクト: 569550384/Rafy
        private void ParseEntity(CodeClass codeClass)
        {
            _currentType = new EntityType();
            _currentType.Name = codeClass.Name;
            _currentType.FullName = codeClass.FullName;
            _currentType.CodeElement = codeClass;
            var baseType = Helper.GetBaseClass(codeClass);
            if (baseType != null) _currentType[BaseTypeFullNameProperty] = baseType.FullName;
            //使用 Attribute 来进行检测是否为聚合根。
            foreach (CodeAttribute attri in codeClass.Attributes)
            {
                if (attri.FullName == Consts.RootEntityAttributeClassFullName)
                {
                    _currentType.IsAggtRoot = true;
                    break;
                }
            }

            //获取模型的注释。
            TryParseDomainName(_currentType, codeClass.DocComment);

            base.VisitClass(codeClass);

            _entityTypes.Add(_currentType);
            _currentType = null;
        }
コード例 #2
0
ファイル: MetaToEOM.cs プロジェクト: 569550384/Rafy
        private EntityType AddEntity(Type entityType, IList<IManagedProperty> properties)
        {
            var type = new EntityType();
            type.Name = entityType.Name;
            type.FullName = entityType.FullName;
            if (entityType.BaseType != null)
            {
                type[BaseTypeFullNameProperty] = entityType.BaseType.FullName;
            }

            foreach (var property in properties)
            {
                if (property is IRefIdProperty)
                {
                    var refProperty = property as IRefProperty;

                    var reference = new Reference();
                    reference.ReferenceType = (Rafy.EntityObjectModel.ReferenceType)refProperty.ReferenceType;//两个枚举的值是相等的。
                    reference.IdProperty = property.Name;
                    reference.Nullable = refProperty.Nullable;
                    if (refProperty.RefEntityProperty != null)
                    {
                        reference.EntityProperty = refProperty.RefEntityProperty.Name;
                    }
                    reference[MPProperty] = refProperty;

                    type.References.Add(reference);
                    continue;
                }
                if (property is IRefEntityProperty) continue;

                if (property is IListProperty)
                {
                    var listProperty = property as IListProperty;
                    if (listProperty.HasManyType == HasManyType.Composition)
                    {
                        var child = new Child();
                        child.Name = listProperty.Name;
                        child.ListTypeFullName = listProperty.PropertyType.FullName;
                        child[MPProperty] = listProperty;

                        type.Children.Add(child);
                        continue;
                    }
                }

                var valueProperty = ConvertToValueProperty(property);
                type.ValueProperties.Add(valueProperty);
            }

            _result.EntityTypes.Add(type);

            return type;
        }
コード例 #3
0
 internal PropertyCollection(EntityType parent)
 {
     this._parent = parent;
 }