Exemple #1
0
        public void Intercept(DispatcherInvocationContext context)
        {
            if (context.Message == null)
            {
                return;
            }

            var command = context.Message as ICommand;

            if (command != null)
            {
                try
                {
                    _logManager.LogCommand(command);
                    context.Invoke();
                    _logManager.LogCommandHandler(command.Metadata.CommandId, context.Handler.GetType().FullName);
                }
                catch (Exception ex)
                {
                    _logManager.LogCommandHandler(command.Metadata.CommandId, context.Handler.GetType().FullName, ex);
                    throw;
                }

                return;
            }

            var evnt = context.Message as IEvent;

            if (evnt != null)
            {
                try
                {
                    _logManager.LogEvent(evnt);
                    context.Invoke();
                    _logManager.LogEventHandler(evnt.Metadata.CommandId, evnt.Metadata.EventId, context.Handler.GetType().FullName);
                }
                catch (Exception ex)
                {
                    _logManager.LogEventHandler(evnt.Metadata.CommandId, evnt.Metadata.EventId, context.Handler.GetType().FullName, ex);
                    throw;
                }

                return;
            }

            // if this is not command or event - execute as usual
            context.Invoke();
        }
        public void Intercept(DispatcherInvocationContext context)
        {
            Tracker.Interceptors.Add(GetType());

            context.Invoke();
        }