public EntityTemplate(EntityDomain entity, IDataTypeFactory dataTypeFactory, EntityTemplate parent)
        {
            Name     = entity.Name;
            DataType = CreateDataTypeName(parent?.DataType, entity.Name);
            Parent   = parent;

            foreach (var attribute in entity.Attributes)
            {
                var dataType = dataTypeFactory.MakeValueDataType(attribute.DataType, attribute.AllowNull);
                if (attribute.IsIdentifier)
                {
                    IdenfierDataType = dataType;
                    IdenfierGuid     = dataType.DataType == EnumDataTypes.Identifier;
                }
                else
                {
                    _attributesTemplate.Add(new AttributeTemplate(attribute, dataType));
                }
            }

            foreach (var element in entity.Elements)
            {
                var dataTypeParameter = CreateDataTypeName(DataType, element.Entity.Name);
                var dataType          = dataTypeFactory.MakeGenericDataType(element.DataType, dataTypeParameter);
                var entityElement     = new EntityTemplate(element.Entity, dataTypeFactory, this);

                var elementTemplate = new ElementTemplate(entityElement, dataType);
                _elementsTemplate.Add(elementTemplate);
                AddReference(elementTemplate);
            }

            Attributes = new CollectionTemplate <AttributeTemplate>(_attributesTemplate);
            Elements   = new CollectionTemplate <ElementTemplate>(_elementsTemplate);
            References = new CollectionTemplate <ElementTemplate>(_referencesTemplate);
        }
        private EntityDomain GetValidEntityWithAttribute()
        {
            var entity = new EntityDomain("EntityTest");

            AddAttributes(entity);
            return(entity);
        }
        public async Task <int> Create(EntityDomain entityDomain)
        {
            using (var context = new InternalDomainCheckerContext(_dbContextOptions))
            {
                context.Domains.Add(entityDomain);
                await context.SaveChangesAsync();

                return(entityDomain.DomainId);
            }
        }
Пример #4
0
 /// <summary>
 /// Create a new entity type.
 /// </summary>
 /// <param name="kin">Kind</param>
 /// <param name="dom">Domain</param>
 /// <param name="coun">Country</param>
 /// <param name="cat">Main category that describes the entity.</param>
 /// <param name="subCat">Sub category to which an entity belongs based on the Category field.</param>
 /// <param name="spec">Specific information about an entity based on the Subcategory field.</param>
 /// <param name="ext">Extra information required to describe a particular entity</param>
 public EntityType(EntityKind kin, EntityDomain dom, Country coun, byte cat, byte subCat, byte spec, byte ext)
 {
     kind        = ( byte )kin;
     domain      = ( byte )dom;
     country     = ( ushort )coun;
     category    = cat;
     subCategory = subCat;
     specific    = spec;
     extra       = ext;
 }
        public void EntityWithInvalidAmountAttributes()
        {
            var entity = new EntityDomain("EntityTest");

            entity.AddAttribute(GetIdentifierAttribute());

            var notifications = new NotificationManager();
            var valid         = entity.IsValid(notifications);

            Assert.False(valid);
            Assert.Contains(nameof(EntityDomain.Attributes), notifications.ToPropertiesNameList());
        }
        public void InvalidEntityName()
        {
            var entity = new EntityDomain(null);

            AddAttributes(entity);

            var notifications = new NotificationManager();
            var valid         = entity.IsValid(notifications);

            Assert.False(valid);
            Assert.Contains(nameof(EntityDomain.Name), notifications.ToPropertiesNameList());
        }
        public async Task <Domain> Create(int orderId, string domain)
        {
            var entityDomain = new EntityDomain
            {
                OrderId    = orderId,
                DomainName = domain
            };

            entityDomain.DomainId = await _iDataServiceDomain.Create(entityDomain);

            return(_iMapper.Map <Domain>(entityDomain));
        }
Пример #8
0
        private EntityDomain CreateEntityDomain(string entityName, bool addElement)
        {
            var entityDomain    = new EntityDomain(new Name(entityName));
            var attributeDomain = new AttributeDomain(
                new Name("Id"),
                EnumDataTypes.String,
                false,
                32
                );

            entityDomain.AddAttribute(attributeDomain);
            if (addElement)
            {
                var entityElementDomain = CreateEntityDomain("ElementChild", false);
                var element             = new ElementDomain(entityElementDomain, EnumDataTypes.Object);
                entityDomain.AddElement(element);
            }
            return(entityDomain);
        }
Пример #9
0
        public static void Register()
        {
            Mapper.Reset();
            Mapper.Initialize(cfg =>
            {
                cfg.CreateMap <AttributeDto, AttributeDomain>(MemberList.None)
                .ConstructUsing(model =>
                                new AttributeDomain(model.Name, model.DataType, model.AllowNull, model.Length))
                .ReverseMap();

                cfg.CreateMap <ElementDto, ElementDomain>(MemberList.None)
                .ConstructUsing((model, context) =>
                {
                    var type   = model.DataType;
                    var entity = context.Mapper.Map <EntityDomain>(model.Entity);
                    return(new ElementDomain(entity, type));
                }).ReverseMap();

                cfg.CreateMap <CreateEntityCommand, EntityDomain>(MemberList.None)
                .ConstructUsing((model, context) =>
                {
                    var entityDomain = new EntityDomain(new Name(model.Name));
                    model?.Attributes.ForEach(attribute =>
                    {
                        var attributeDomain = context.Mapper.Map <AttributeDomain>(attribute);
                        entityDomain.AddAttribute(attributeDomain);
                    });
                    model?.Elements.ForEach(element =>
                    {
                        var elementDomain = context.Mapper.Map <ElementDomain>(element);
                        entityDomain.AddElement(elementDomain);
                    });
                    return(entityDomain);
                }).ReverseMap();

                cfg.CreateMap <EntityDomain, EntityQueryResult>(MemberList.Destination);
                cfg.CreateMap <AttributeDomain, AttributeQueryResult>(MemberList.Destination);
                cfg.CreateMap <ElementDomain, ElementQueryResult>(MemberList.Destination);
            });
        }
 private void AddAttributes(EntityDomain entity)
 {
     entity.AddAttribute(GetIdentifierAttribute());
     entity.AddAttribute(GetNameAttribute());
 }
Пример #11
0
 public IEnumerable <IEvent> GetCommittedEventsInRange(Guid sessionIdFrom, Guid sessionIdTo, EntityDomain entityDomain)
 {
     return(_leanPlatform.GetCommittedEventsInRange(sessionIdFrom, sessionIdTo, entityDomain));
 }
Пример #12
0
 public IEnumerable <IEvent> GetCommittedEvents(Guid lastSessionId, EntityDomain entityDomain)
 {
     return(_leanPlatform.GetCommittedEvents(lastSessionId, entityDomain));
 }
Пример #13
0
 public IEvent GetCommittedEvent(Guid sessionId, EntityDomain entityDomain)
 {
     return(_leanPlatform.GetCommittedEvent(sessionId, entityDomain));
 }
 public EntityTemplate(EntityDomain entity, IDataTypeFactory dataTypeFactory)
     : this(entity, dataTypeFactory, null)
 {
 }