public void HandleEvent(PostActionHookEvent eventMessage)
        {
            var entries = eventMessage.ModifiedEntries;

            if (!entries.Any() || !_postHooks.Any())
            {
                return;
            }

            foreach (var entry in entries)
            {
                var e         = entry;         // Prevents access to modified closure
                var postHooks = GetPostHookInstancesFor(e.Entity.GetType());
                foreach (var hook in postHooks)
                {
                    if (hook.HookStates == e.PreSaveState)
                    {
                        var metadata = new HookEntityMetadata(e.PreSaveState);
                        using (var scope = new DbContextScope(hooksEnabled: false))
                        {
                            // dead end: don't let hooks call hooks again
                            hook.HookObject(e.Entity, metadata);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void HandleEvent(PostActionHookEvent eventMessage)
        {
            var entries = eventMessage.ModifiedEntries;

            if (!entries.Any() || !_postHooks.Any())
            {
                return;
            }

            foreach (var entry in entries)
            {
                var e         = entry;         // Prevents access to modified closure
                var postHooks = GetPostHookInstancesFor(e.Entity.GetType());
                foreach (var hook in postHooks)
                {
                    if (hook.HookStates == e.PreSaveState)
                    {
                        var metadata = new HookEntityMetadata(e.PreSaveState);
                        hook.HookObject(e.Entity, metadata);
                    }
                }
            }
        }