private void OnEntityDefinitionDeleted(EntityDefinitionDeleted e)
        {
            EntityDefinition entity = this.entities.FirstOrDefault(i => i.Id == e.EntityId);

            if (entity != null)
            {
                this.entities.Remove(entity);
            }
        }
        public ConfigurationEntry(IEventAggregator eventAggregator, EntityDefinition entityDefinition, Guid entryId, IEnumerable <ConfigurationValue> values)
            : base(eventAggregator, entryId)
        {
            this.Definition = entityDefinition.ArgumentNotNull(nameof(entityDefinition));
            this.values     = values.ArgumentNotNull(nameof(values)).ToDictionary(k => k.Property.Id);

            this.EventAggregator.Subscribe <PropertyDefinitionAdded>(this.OnPropertyDefinitionAdded, e => e.ParentEntityId == this.Definition.Id);
            this.EventAggregator.Subscribe <PropertyDefinitionDeleted>(this.OnPropertyDefinitionDeleted);
            this.EventAggregator.Subscribe <ConfigurationEntryModified>(this.OnConfigurationEntryModified, e => e.EntryId == this.Id);
        }
Exemplo n.º 3
0
        private EntityDefinition GetEntityDefinition(Guid entityId)
        {
            EntityDefinition entity = this.Schema.Entities.SingleOrDefault(i => i.Id == entityId);

            if (entity == null)
            {
                throw new ArgumentException($"No entity definition with id {entityId} was found.", nameof(entityId));
            }

            return(entity);
        }
Exemplo n.º 4
0
        public void AddPropertyDefinition(Guid entityId, string name, string description, string propertyType)
        {
            name.ArgumentNotNullOrEmpty(nameof(name));
            description.ArgumentNotNull(nameof(description));
            propertyType.ArgumentNotNullOrEmpty(nameof(propertyType));

            // the entity gets fetched to assert its existence.
            EntityDefinition entity = this.GetEntityDefinition(entityId);

            var e = new PropertyDefinitionAdded
            {
                Id             = this.Id,
                ParentEntityId = entity.Id,
                PropertyId     = Guid.NewGuid(),
                Name           = name,
                Description    = description,
                PropertyType   = propertyType
            };

            this.ApplyChange(e);
        }
        private void OnEntityDefinitionAdded(EntityDefinitionAdded e)
        {
            var entity = new EntityDefinition(this.EventAggregator, e.EntityId, e.Name, e.Description);

            this.entities.Add(entity);
        }