예제 #1
0
파일: EntityInfo.cs 프로젝트: sGeeK44/Orm
 private EntityInfo(IFieldPropertyFactory fieldPropertyFactory, EntityInfoCollection entities, Type entityType)
 {
     Fields               = new DistinctCollection <Field>();
     ForeignKeys          = new DistinctCollection <ForeignKey>();
     References           = new DistinctCollection <Reference>();
     Indexes              = new DistinctCollection <Index>();
     Entities             = entities;
     EntityType           = entityType;
     _attributes          = entityType.GetCustomAttributes(true);
     FieldPropertyFactory = fieldPropertyFactory;
 }
예제 #2
0
파일: EntityInfo.cs 프로젝트: sGeeK44/Orm
        public static IEntityInfo Create(IFieldPropertyFactory fieldPropertyFactory, EntityInfoCollection entities,
                                         Type entityType)
        {
            if (entities == null)
            {
                throw new ArgumentNullException("entities");
            }

            // already added
            var entityName = entities.GetNameForType(entityType);

            if (entityName != null)
            {
                return(entities[entityName]);
            }

            //TODO: validate NameInStore
            var result = new EntityInfo(fieldPropertyFactory, entities, entityType);

            if (result.EntityAttribute == null)
            {
                throw new ArgumentException($"Type '{entityType.Name}' does not have an EntityAttribute");
            }

            entities.Add(result);

            // see if we have any entity
            // get all field definitions
            foreach (var prop in GetProperties(entityType))
            {
                result.AnalyseAttribute(prop);
            }

            if (result.Fields.Count == 0)
            {
                throw new EntityDefinitionException(
                          $"Entity '{result.GetNameInStore()}' Contains no Field definitions.");
            }

            //Update Reference atribute with new known type
            foreach (var entityInfo in entities)
            {
                var entity = entityInfo as EntityInfo;

                entity?.UpdateRefenceAttribute();
            }

            return(result);
        }
예제 #3
0
파일: DataStore.cs 프로젝트: sGeeK44/Orm
 protected DataStore()
 {
     Entities = new EntityInfoCollection();
 }