Update exchange/routingKey when selecting a Tapeti message class
Slightly improved Raw/Tapeti switching UI
This commit is contained in:
parent
91725b2c0d
commit
a4f85b0f07
@ -17,11 +17,13 @@ namespace PettingZoo.Core.Generator
|
|||||||
|
|
||||||
public interface IClassTypeExample : IExample
|
public interface IClassTypeExample : IExample
|
||||||
{
|
{
|
||||||
public string AssemblyName { get; }
|
string AssemblyName { get; }
|
||||||
public string? Namespace { get; }
|
string? Namespace { get; }
|
||||||
public string ClassName { get; }
|
string ClassName { get; }
|
||||||
|
|
||||||
public string FullClassName => (!string.IsNullOrEmpty(Namespace) ? Namespace + "." : "") + ClassName;
|
string FullClassName => (!string.IsNullOrEmpty(Namespace) ? Namespace + "." : "") + ClassName;
|
||||||
|
|
||||||
|
bool TryGetPublishDestination(out string exchange, out string routingKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ using System.Runtime.Loader;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using PettingZoo.Core.Generator;
|
using PettingZoo.Core.Generator;
|
||||||
using PettingZoo.Core.Validation;
|
using PettingZoo.Core.Validation;
|
||||||
|
using Tapeti.Default;
|
||||||
|
|
||||||
namespace PettingZoo.Tapeti.AssemblyParser
|
namespace PettingZoo.Tapeti.AssemblyParser
|
||||||
{
|
{
|
||||||
@ -83,6 +84,24 @@ namespace PettingZoo.Tapeti.AssemblyParser
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public bool TryGetPublishDestination(out string exchange, out string routingKey)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Assume default strategies are used
|
||||||
|
exchange = new NamespaceMatchExchangeStrategy().GetExchange(type);
|
||||||
|
routingKey = new TypeNameRoutingKeyStrategy().GetRoutingKey(type);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
exchange = "";
|
||||||
|
routingKey = "";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public bool CanValidate()
|
public bool CanValidate()
|
||||||
{
|
{
|
||||||
return InitializeValidation();
|
return InitializeValidation();
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||||
<PackageReference Include="System.Reactive" Version="5.0.0" />
|
<PackageReference Include="System.Reactive" Version="5.0.0" />
|
||||||
<PackageReference Include="System.Reflection.MetadataLoadContext" Version="6.0.0" />
|
<PackageReference Include="System.Reflection.MetadataLoadContext" Version="6.0.0" />
|
||||||
|
<PackageReference Include="Tapeti" Version="2.8.2" />
|
||||||
<PackageReference Include="Tapeti.Annotations" Version="3.0.0" />
|
<PackageReference Include="Tapeti.Annotations" Version="3.0.0" />
|
||||||
<PackageReference Include="Tapeti.DataAnnotations.Extensions" Version="3.0.0" />
|
<PackageReference Include="Tapeti.DataAnnotations.Extensions" Version="3.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -300,6 +300,14 @@ namespace PettingZoo.Tapeti.UI.ClassSelection
|
|||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public bool TryGetPublishDestination(out string exchange, out string routingKey)
|
||||||
|
{
|
||||||
|
exchange = "";
|
||||||
|
routingKey = "";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,12 @@
|
|||||||
</Style.Triggers>
|
</Style.Triggers>
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
|
<Style x:Key="ButtonIcon" TargetType="{x:Type Image}">
|
||||||
|
<Setter Property="Margin" Value="0,0,8,0" />
|
||||||
|
<Setter Property="Width" Value="16" />
|
||||||
|
<Setter Property="Height" Value="16" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
|
||||||
<Style x:Key="Timestamp" TargetType="{x:Type TextBlock}">
|
<Style x:Key="Timestamp" TargetType="{x:Type TextBlock}">
|
||||||
<Style.Triggers>
|
<Style.Triggers>
|
||||||
|
6
PettingZoo/Images/RabbitMQ.svg
Normal file
6
PettingZoo/Images/RabbitMQ.svg
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg width="256px" height="271px" viewBox="0 0 256 271" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid">
|
||||||
|
<g>
|
||||||
|
<path d="M245.44,108.307692 L160.349538,108.307692 C156.081231,108.307692 152.615385,104.841846 152.615385,100.573538 L152.615385,11.8941538 C152.615385,5.32676923 147.288615,0 140.726154,0 L110.350769,0 C103.783385,0 98.4615385,5.32676923 98.4615385,11.8941538 L98.4615385,100.036923 C98.4615385,104.610462 94.7643077,108.327385 90.1907692,108.347077 L62.3064615,108.48 C57.6935385,108.504615 53.9470769,104.763077 53.9569231,100.155077 L54.1292308,11.9138462 C54.144,5.33661538 48.8172308,0 42.24,0 L11.8892308,0 C5.32184615,0 0,5.32676923 0,11.8941538 L0,260.209231 C0,266.043077 4.72615385,270.769231 10.5550769,270.769231 L245.44,270.769231 C251.273846,270.769231 256,266.043077 256,260.209231 L256,118.867692 C256,113.033846 251.273846,108.307692 245.44,108.307692 L245.44,108.307692 Z M205.538462,201.540923 C205.538462,209.186462 199.340308,215.384615 191.694769,215.384615 L167.689846,215.384615 C160.044308,215.384615 153.846154,209.186462 153.846154,201.540923 L153.846154,177.536 C153.846154,169.890462 160.044308,163.692308 167.689846,163.692308 L191.694769,163.692308 C199.340308,163.692308 205.538462,169.890462 205.538462,177.536 L205.538462,201.540923 L205.538462,201.540923 Z" fill="#FF6600"></path>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 1.4 KiB |
BIN
PettingZoo/Images/Tapeti.png
Normal file
BIN
PettingZoo/Images/Tapeti.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.5 KiB |
@ -28,6 +28,8 @@
|
|||||||
<None Remove="Images\Import.svg" />
|
<None Remove="Images\Import.svg" />
|
||||||
<None Remove="Images\Ok.svg" />
|
<None Remove="Images\Ok.svg" />
|
||||||
<None Remove="Images\PublishSend.svg" />
|
<None Remove="Images\PublishSend.svg" />
|
||||||
|
<None Remove="Images\RabbitMQ.svg" />
|
||||||
|
<None Remove="Images\Tapeti.png" />
|
||||||
<None Remove="Images\Undock.svg" />
|
<None Remove="Images\Undock.svg" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
@ -44,6 +46,7 @@
|
|||||||
<Resource Include="Images\Ok.svg" />
|
<Resource Include="Images\Ok.svg" />
|
||||||
<Resource Include="Images\Publish.svg" />
|
<Resource Include="Images\Publish.svg" />
|
||||||
<Resource Include="Images\PublishSend.svg" />
|
<Resource Include="Images\PublishSend.svg" />
|
||||||
|
<Resource Include="Images\RabbitMQ.svg" />
|
||||||
<Resource Include="Images\Subscribe.svg" />
|
<Resource Include="Images\Subscribe.svg" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
@ -66,6 +69,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Resource Include="Images\Tapeti.png" />
|
||||||
<Resource Include="Images\Undock.svg" />
|
<Resource Include="Images\Undock.svg" />
|
||||||
<Resource Include="Images\Busy.svg" />
|
<Resource Include="Images\Busy.svg" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -6,5 +6,6 @@
|
|||||||
string RoutingKey { get; }
|
string RoutingKey { get; }
|
||||||
|
|
||||||
string? GetReplyTo(ref string? correlationId);
|
string? GetReplyTo(ref string? correlationId);
|
||||||
|
void SetExchangeDestination(string exchange, string routingKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:res="clr-namespace:PettingZoo.UI.Tab.Publisher"
|
xmlns:res="clr-namespace:PettingZoo.UI.Tab.Publisher"
|
||||||
xmlns:controls="clr-namespace:PettingZoo.WPF.Controls;assembly=PettingZoo.WPF"
|
xmlns:controls="clr-namespace:PettingZoo.WPF.Controls;assembly=PettingZoo.WPF"
|
||||||
|
xmlns:svgc="http://sharpvectors.codeplex.com/svgc/"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="450"
|
d:DesignHeight="450"
|
||||||
d:DesignWidth="800"
|
d:DesignWidth="800"
|
||||||
@ -13,6 +14,8 @@
|
|||||||
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
||||||
<controls:GridLayout Style="{StaticResource Form}" Margin="4" Grid.IsSharedSizeScope="True">
|
<controls:GridLayout Style="{StaticResource Form}" Margin="4" Grid.IsSharedSizeScope="True">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="8"/>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
@ -20,8 +23,7 @@
|
|||||||
<RowDefinition Height="16"/>
|
<RowDefinition Height="16"/>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition Height="16"/>
|
<RowDefinition Height="16" />
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
@ -30,37 +32,47 @@
|
|||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
<Label Grid.Row="0" Grid.Column="1">
|
<StackPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="1">
|
||||||
|
<ToggleButton Style="{StaticResource TypeSelection}" IsChecked="{Binding MessageTypeRaw}">
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<Image Source="{svgc:SvgImage Source=/Images/RabbitMQ.svg, AppName=PettingZoo}" Style="{StaticResource ButtonIcon}" />
|
||||||
|
<TextBlock Text="{x:Static res:PublisherViewStrings.OptionMessageTypeRaw}" />
|
||||||
|
</StackPanel>
|
||||||
|
</ToggleButton>
|
||||||
|
<ToggleButton Style="{StaticResource TypeSelection}" IsChecked="{Binding MessageTypeTapeti}">
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<Image Source="/Images/Tapeti.png" Style="{StaticResource ButtonIcon}" />
|
||||||
|
<TextBlock Text="{x:Static res:PublisherViewStrings.OptionMessageTypeTapeti}" />
|
||||||
|
</StackPanel>
|
||||||
|
</ToggleButton>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<Label Grid.Row="2" Grid.Column="1">
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<RadioButton Content="{x:Static res:PublisherViewStrings.LabelSendToExchange}" IsChecked="{Binding SendToExchange}" Style="{StaticResource TypeSelection}" />
|
<RadioButton Content="{x:Static res:PublisherViewStrings.LabelSendToExchange}" IsChecked="{Binding SendToExchange}" Style="{StaticResource TypeSelection}" />
|
||||||
<RadioButton Content="{x:Static res:PublisherViewStrings.LabelSendToQueue}" IsChecked="{Binding SendToQueue}" Style="{StaticResource TypeSelection}" />
|
<RadioButton Content="{x:Static res:PublisherViewStrings.LabelSendToQueue}" IsChecked="{Binding SendToQueue}" Style="{StaticResource TypeSelection}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Label>
|
</Label>
|
||||||
|
|
||||||
<Label Grid.Row="1" Grid.Column="0" Content="{x:Static res:PublisherViewStrings.LabelExchange}" Visibility="{Binding ExchangeVisibility}" />
|
<Label Grid.Row="3" Grid.Column="0" Content="{x:Static res:PublisherViewStrings.LabelExchange}" Visibility="{Binding ExchangeVisibility}" />
|
||||||
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Exchange, UpdateSourceTrigger=PropertyChanged}" Visibility="{Binding ExchangeVisibility}" />
|
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding Exchange, UpdateSourceTrigger=PropertyChanged}" Visibility="{Binding ExchangeVisibility}" />
|
||||||
|
|
||||||
<Label Grid.Row="2" Grid.Column="0" Content="{x:Static res:PublisherViewStrings.LabelRoutingKey}" Visibility="{Binding ExchangeVisibility}" />
|
<Label Grid.Row="4" Grid.Column="0" Content="{x:Static res:PublisherViewStrings.LabelRoutingKey}" Visibility="{Binding ExchangeVisibility}" />
|
||||||
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding RoutingKey, UpdateSourceTrigger=PropertyChanged}" Visibility="{Binding ExchangeVisibility}" />
|
<TextBox Grid.Row="4" Grid.Column="1" Text="{Binding RoutingKey, UpdateSourceTrigger=PropertyChanged}" Visibility="{Binding ExchangeVisibility}" />
|
||||||
|
|
||||||
<Label Grid.Row="3" Grid.Column="0" Content="{x:Static res:PublisherViewStrings.LabelQueue}" Visibility="{Binding QueueVisibility}" />
|
<Label Grid.Row="5" Grid.Column="0" Content="{x:Static res:PublisherViewStrings.LabelQueue}" Visibility="{Binding QueueVisibility}" />
|
||||||
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding Queue, UpdateSourceTrigger=PropertyChanged}" Visibility="{Binding QueueVisibility}" />
|
<TextBox Grid.Row="5" Grid.Column="1" Text="{Binding Queue, UpdateSourceTrigger=PropertyChanged}" Visibility="{Binding QueueVisibility}" />
|
||||||
|
|
||||||
<Label Grid.Row="5" Grid.Column="0" Content="{x:Static res:PublisherViewStrings.LabelReplyTo}" />
|
<Label Grid.Row="7" Grid.Column="0" Content="{x:Static res:PublisherViewStrings.LabelReplyTo}" />
|
||||||
<StackPanel Orientation="Horizontal" Grid.Row="5" Grid.Column="1">
|
<StackPanel Orientation="Horizontal" Grid.Row="7" Grid.Column="1">
|
||||||
<RadioButton Content="{x:Static res:PublisherViewStrings.LabelReplyToSpecified}" IsChecked="{Binding ReplyToSpecified}" Style="{StaticResource TypeSelection}" />
|
<RadioButton Content="{x:Static res:PublisherViewStrings.LabelReplyToSpecified}" IsChecked="{Binding ReplyToSpecified}" Style="{StaticResource TypeSelection}" />
|
||||||
<RadioButton Content="{x:Static res:PublisherViewStrings.LabelReplyToNewSubscriber}" IsChecked="{Binding ReplyToNewSubscriber}" Style="{StaticResource TypeSelection}" />
|
<RadioButton Content="{x:Static res:PublisherViewStrings.LabelReplyToNewSubscriber}" IsChecked="{Binding ReplyToNewSubscriber}" Style="{StaticResource TypeSelection}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<TextBox Grid.Row="6" Grid.Column="1" Text="{Binding ReplyTo}" IsEnabled="{Binding ReplyToSpecified}" />
|
<TextBox Grid.Row="8" Grid.Column="1" Text="{Binding ReplyTo}" IsEnabled="{Binding ReplyToSpecified}" />
|
||||||
|
|
||||||
<StackPanel Orientation="Horizontal" Grid.Row="8" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Center">
|
<ContentControl Grid.Row="10" Grid.Column="0" Grid.ColumnSpan="2" Margin="0 8 0 0" Content="{Binding MessageTypeControl}" />
|
||||||
<ToggleButton Content="{x:Static res:PublisherViewStrings.OptionMessageTypeRaw}" Style="{StaticResource TypeSelection}" IsChecked="{Binding MessageTypeRaw}" />
|
|
||||||
<ToggleButton Content="{x:Static res:PublisherViewStrings.OptionMessageTypeTapeti}" Style="{StaticResource TypeSelection}" IsChecked="{Binding MessageTypeTapeti}" />
|
|
||||||
</StackPanel>
|
|
||||||
|
|
||||||
<ContentControl Grid.Row="9" Grid.Column="0" Grid.ColumnSpan="2" Margin="0 8 0 0" Content="{Binding MessageTypeControl}" />
|
<Button Grid.Row="11" Grid.Column="1" Command="{Binding PublishCommand}" Content="{x:Static res:PublisherViewStrings.CommandPublish}" HorizontalAlignment="Left" />
|
||||||
|
|
||||||
<Button Grid.Row="10" Grid.Column="1" Command="{Binding PublishCommand}" Content="{x:Static res:PublisherViewStrings.CommandPublish}" HorizontalAlignment="Left" />
|
|
||||||
</controls:GridLayout>
|
</controls:GridLayout>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
@ -288,6 +288,13 @@ namespace PettingZoo.UI.Tab.Publisher
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void SetExchangeDestination(string newExchange, string newRoutingKey)
|
||||||
|
{
|
||||||
|
Exchange = newExchange;
|
||||||
|
RoutingKey = newRoutingKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void HostWindowChanged(Window? hostWindow)
|
public void HostWindowChanged(Window? hostWindow)
|
||||||
{
|
{
|
||||||
tabHostWindow = hostWindow;
|
tabHostWindow = hostWindow;
|
||||||
|
@ -134,6 +134,9 @@ namespace PettingZoo.UI.Tab.Publisher
|
|||||||
AssemblyName = classTypeExample.AssemblyName;
|
AssemblyName = classTypeExample.AssemblyName;
|
||||||
ClassName = classTypeExample.FullClassName;
|
ClassName = classTypeExample.FullClassName;
|
||||||
|
|
||||||
|
if (classTypeExample.TryGetPublishDestination(out var exchange, out var routingKey))
|
||||||
|
publishDestination.SetExchangeDestination(exchange, routingKey);
|
||||||
|
|
||||||
validatingExample = classTypeExample as IValidatingExample;
|
validatingExample = classTypeExample as IValidatingExample;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user