From 4817b1806a5ef52c92940f492977364949147f4a Mon Sep 17 00:00:00 2001 From: Mark van Renswoude Date: Wed, 15 Dec 2021 13:16:48 +0100 Subject: [PATCH] Fixed assembly/classname when publishing from a received message --- PettingZoo/UI/Connection/ConnectionViewModel.cs | 1 + PettingZoo/UI/Tab/Publisher/PublisherViewModel.cs | 4 ++-- PettingZoo/UI/Tab/Publisher/RawPublisherViewModel.cs | 8 ++++++++ PettingZoo/UI/Tab/Publisher/TapetiPublisherViewModel.cs | 7 ++++--- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/PettingZoo/UI/Connection/ConnectionViewModel.cs b/PettingZoo/UI/Connection/ConnectionViewModel.cs index b1eacb6..859afde 100644 --- a/PettingZoo/UI/Connection/ConnectionViewModel.cs +++ b/PettingZoo/UI/Connection/ConnectionViewModel.cs @@ -2,6 +2,7 @@ using System.Windows.Input; // TODO validate input +// TODO profiles namespace PettingZoo.UI.Connection { diff --git a/PettingZoo/UI/Tab/Publisher/PublisherViewModel.cs b/PettingZoo/UI/Tab/Publisher/PublisherViewModel.cs index d25f256..00aa15d 100644 --- a/PettingZoo/UI/Tab/Publisher/PublisherViewModel.cs +++ b/PettingZoo/UI/Tab/Publisher/PublisherViewModel.cs @@ -139,14 +139,14 @@ namespace PettingZoo.UI.Tab.Publisher var tapetiPublisherViewModel = new TapetiPublisherViewModel(connection, fromReceivedMessage); tapetiPublisherView = new TapetiPublisherView(tapetiPublisherViewModel); - SetMessageTypeControl(MessageType.Tapeti); + MessageType = MessageType.Tapeti; } else { var rawPublisherViewModel = new RawPublisherViewModel(connection, fromReceivedMessage); rawPublisherView = new RawPublisherView(rawPublisherViewModel); - SetMessageTypeControl(MessageType.Raw); + MessageType = MessageType.Raw; } } } diff --git a/PettingZoo/UI/Tab/Publisher/RawPublisherViewModel.cs b/PettingZoo/UI/Tab/Publisher/RawPublisherViewModel.cs index 7ad2b10..33e90ae 100644 --- a/PettingZoo/UI/Tab/Publisher/RawPublisherViewModel.cs +++ b/PettingZoo/UI/Tab/Publisher/RawPublisherViewModel.cs @@ -226,12 +226,20 @@ namespace PettingZoo.UI.Tab.Publisher Key = header.Key, Value = header.Value }); + + PropertiesExpanded = AnyNotEmpty(AppId, ContentEncoding, Expiration, MessageId, Priority, Timestamp, TypeProperty, UserId); } AddHeader(); } + private static bool AnyNotEmpty(params string?[] values) + { + return values.Any(s => !string.IsNullOrEmpty(s)); + } + + private void LastHeaderChanged(object? sender, PropertyChangedEventArgs e) { LastHeader.PropertyChanged -= LastHeaderChanged; diff --git a/PettingZoo/UI/Tab/Publisher/TapetiPublisherViewModel.cs b/PettingZoo/UI/Tab/Publisher/TapetiPublisherViewModel.cs index 07c4362..a4de74f 100644 --- a/PettingZoo/UI/Tab/Publisher/TapetiPublisherViewModel.cs +++ b/PettingZoo/UI/Tab/Publisher/TapetiPublisherViewModel.cs @@ -149,14 +149,15 @@ namespace PettingZoo.UI.Tab.Publisher publishCommand = new DelegateCommand(PublishExecute, PublishCanExecute); - if (receivedMessage == null) + if (receivedMessage == null || !IsTapetiMessage(receivedMessage, out var receivedAssemblyName, out var receivedClassName)) return; Exchange = receivedMessage.Exchange; RoutingKey = receivedMessage.RoutingKey; - AssemblyName = assemblyName; - ClassName = className; + + AssemblyName = receivedAssemblyName; + ClassName = receivedClassName; CorrelationId = receivedMessage.Properties.CorrelationId ?? ""; ReplyTo = receivedMessage.Properties.ReplyTo ?? ""; Payload = Encoding.UTF8.GetString(receivedMessage.Body);