Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
        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(string.Format("Type '{0}' does not have an EntityAttribute", entityType.Name));
            }

            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(string.Format("Entity '{0}' Contains no Field definitions.", result.GetNameInStore()));
            }

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

                entity.UpdateRefenceAttribute();
            }

            return(result);
        }
Ejemplo n.º 3
0
 protected DataStore()
 {
     Entities = new EntityInfoCollection();
 }