Beispiel #1
0
 internal static void DispatchEvent(EntityEvent entityEvent, Type entityType,
                                    BaseEntityContext context, DbEntityEntry entry)
 {
     foreach (var eventListener in entitiesChangedListeners.Where(c => TypeHelper.IsSameOrSubclass(c.Key, entityType)))
     {
         IEntityListener listener = (IEntityListener)Activator.CreateInstance(eventListener.Value, false);
         listener.OnEntityEvent(entityEvent, context, entry);
     }
 }
Beispiel #2
0
            public override void PostCreate(BaseEntityContext context, DbEntityEntry createdEntries)
            {
                DynamicEntityContext dynamicContext = (DynamicEntityContext)context;
                var entity    = (IEntity)createdEntries.Entity;
                var attribute = dynamicContext.Create <IAttribute>();

                attribute.Name = "AttributeCreatedByTestListener";

                entity.Attributes.Add(attribute);

                context.SaveChanges();
            }
Beispiel #3
0
        public void OnEntityEvent(EventDispatcher.EntityEvent entityEvent, BaseEntityContext context, DbEntityEntry entity)
        {
            switch (entityEvent)
            {
            case EventDispatcher.EntityEvent.PostUpdate:    PreUpdate(context, entity); break;

            case EventDispatcher.EntityEvent.PostDelete:    PostDelete(context, entity); break;

            case EventDispatcher.EntityEvent.PostCreate:    PostCreate(context, entity); break;

            case EventDispatcher.EntityEvent.PreUpdate:     PreUpdate(context, entity); break;

            case EventDispatcher.EntityEvent.PreDelete:     PreDelete(context, entity); break;

            case EventDispatcher.EntityEvent.PreCreate:     PreCreate(context, entity); break;
            }
        }
Beispiel #4
0
 public override void PreDelete(BaseEntityContext context, DbEntityEntry deletingEntries)
 {
     throw new NotImplementedException();
 }
Beispiel #5
0
 public override void PostUpdate(BaseEntityContext context, DbEntityEntry updatedEntries)
 {
     throw new NotImplementedException();
 }
Beispiel #6
0
            public override void PreCreate(BaseEntityContext context, DbEntityEntry creatingEntries)
            {
                var entity = (IEntity)creatingEntries.Entity;

                entity.Name = "ModifiedByTestListener";
            }
Beispiel #7
0
 public abstract void PreCreate(BaseEntityContext context, DbEntityEntry creatingEntries);
Beispiel #8
0
 public abstract void PreDelete(BaseEntityContext context, DbEntityEntry deletingEntries);
Beispiel #9
0
 public abstract void PreUpdate(BaseEntityContext context, DbEntityEntry updatingEntries);
Beispiel #10
0
 public abstract void PostCreate(BaseEntityContext context, DbEntityEntry createdEntries);
Beispiel #11
0
 public abstract void PostDelete(BaseEntityContext context, DbEntityEntry deletedEntries);
Beispiel #12
0
 public abstract void PostUpdate(BaseEntityContext context, DbEntityEntry updatedEntries);