Esempio n. 1
0
        private void GetValue(InteractionMessageRaisedEventArgs e, InteractionMessage cloneMessage)
        {
            InteractionMessenger sourceResult;
            var result = _source.TryGetTarget(out sourceResult);

            if (!result)
            {
                return;
            }

            if (e.Message.MessageKey != null)
            {
                ConcurrentBag <Action <InteractionMessage> > list;
                _actionDictionary.TryGetValue(e.Message.MessageKey, out list);

                if (list != null)
                {
                    foreach (var action in list)
                    {
                        action(cloneMessage);
                    }
                }
            }

            ConcurrentBag <Action <InteractionMessage> > allList;

            _actionDictionary.TryGetValue(string.Empty, out allList);
            if (allList != null)
            {
                foreach (var action in allList)
                {
                    action(cloneMessage);
                }
            }
        }
Esempio n. 2
0
        private void MessageReceived(object sender, [NotNull] InteractionMessageRaisedEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException(nameof(e));
            }
            if (_disposed)
            {
                return;
            }

            var message       = e.Message;
            var clonedMessage = (InteractionMessage)message.Clone();

            clonedMessage.Freeze();

            DoActionOnDispatcher(() => { GetValue(e, clonedMessage); });

            var responsiveMessage = message as ResponsiveInteractionMessage;

            object response;

            if (responsiveMessage != null &&
                (response = ((ResponsiveInteractionMessage)clonedMessage).Response) != null)
            {
                responsiveMessage.Response = response;
            }
        }
Esempio n. 3
0
        private void GetValue([NotNull] InteractionMessageRaisedEventArgs e, InteractionMessage cloneMessage)
        {
            if (e == null)
            {
                throw new ArgumentNullException(nameof(e));
            }

            var result = _source.TryGetTarget(out _);

            if (!result)
            {
                return;
            }

            if (e.Message.MessageKey != null)
            {
                _actionDictionary.TryGetValue(e.Message.MessageKey, out var list);

                if (list != null)
                {
                    foreach (var action in list)
                    {
                        action(cloneMessage);
                    }
                }
            }

            _actionDictionary.TryGetValue(string.Empty, out var allList);
            if (allList == null)
            {
                return;
            }

            foreach (var action in allList)
            {
                action(cloneMessage);
            }
        }
Esempio n. 4
0
        private void MessageReceived(object sender, InteractionMessageRaisedEventArgs e)
        {
            var message = e.Message;

            var cloneMessage = (InteractionMessage)message.Clone();

            cloneMessage.Freeze();

            DoActionOnDispatcher(() =>
            {
                GetValue(e, cloneMessage);
            });

            var responsiveMessage = message as ResponsiveInteractionMessage;

            object response;

            if (responsiveMessage != null &&
                (response = ((ResponsiveInteractionMessage)cloneMessage).Response) != null)
            {
                responsiveMessage.Response = response;
            }
        }