From 7d414e770ee52d8c629ee2ff02b88e73c7be75c5 Mon Sep 17 00:00:00 2001
From: john-ciq <87781711+john-ciq@users.noreply.github.com>
Date: Thu, 16 May 2024 16:25:42 -0400
Subject: [PATCH] Update examples for 8.11.0
---
.../AuthenticationExample.csproj | 4 +-
AuthenticationExample/packages.config | 2 +-
FDC3WPFExample/FDC3WPFExample.csproj | 4 +-
FDC3WPFExample/packages.config | 2 +-
MultiWindowExample/App.xaml.cs | 1 +
MultiWindowExample/IIntegrateable.cs | 7 +-
MultiWindowExample/MultiWindowExample.csproj | 4 +-
MultiWindowExample/SingleInstance.cs | 70 +++++++-----------
MultiWindowExample/packages.config | 2 +-
WPFExample/MainWindow.xaml.cs | 44 +++++++++++-
WPFExample/WPFExample.csproj | 4 +-
WPFExample/packages.config | 2 +-
WPFExampleCore/MainWindow.xaml.cs | 28 +++++++-
WPFExampleCore/WPFExampleCore.csproj | 2 +-
.../WPFMultiWindowExampleCore.csproj | 2 +-
.../WindowlessExample.Core.csproj | 4 +-
WindowlessExample/WindowlessExample.csproj | 4 +-
WindowlessExample/packages.config | 2 +-
WinformExample/FormExample.cs | 72 +++++++++++++------
WinformExample/WinformExample.csproj | 4 +-
WinformExample/packages.config | 2 +-
WinformExampleCore/MainForm.cs | 21 +++++-
WinformExampleCore/WinformExampleCore.csproj | 2 +-
.../WinformMultiWindowExample.csproj | 4 +-
WinformMultiWindowExample/packages.config | 2 +-
.../WinformMultiWindowExampleCore.csproj | 2 +-
26 files changed, 194 insertions(+), 103 deletions(-)
diff --git a/AuthenticationExample/AuthenticationExample.csproj b/AuthenticationExample/AuthenticationExample.csproj
index bd9e58b..efc010a 100644
--- a/AuthenticationExample/AuthenticationExample.csproj
+++ b/AuthenticationExample/AuthenticationExample.csproj
@@ -49,8 +49,8 @@
..\packages\DotNetZip.1.16.0\lib\net40\DotNetZip.dll
-
- ..\packages\Finsemble.8.9.3\lib\net452\Finsemble.dll
+
+ ..\packages\Finsemble.8.11.0\lib\net452\Finsemble.dll
..\packages\Microsoft.IdentityModel.Logging.6.16.0\lib\net45\Microsoft.IdentityModel.Logging.dll
diff --git a/AuthenticationExample/packages.config b/AuthenticationExample/packages.config
index 1ff02da..c130ec9 100644
--- a/AuthenticationExample/packages.config
+++ b/AuthenticationExample/packages.config
@@ -1,7 +1,7 @@
-
+
diff --git a/FDC3WPFExample/FDC3WPFExample.csproj b/FDC3WPFExample/FDC3WPFExample.csproj
index 63fb7ae..91eca2b 100644
--- a/FDC3WPFExample/FDC3WPFExample.csproj
+++ b/FDC3WPFExample/FDC3WPFExample.csproj
@@ -49,8 +49,8 @@
..\packages\DotNetZip.1.16.0\lib\net40\DotNetZip.dll
-
- ..\packages\Finsemble.8.9.3\lib\net452\Finsemble.dll
+
+ ..\packages\Finsemble.8.11.0\lib\net452\Finsemble.dll
..\packages\Microsoft.IdentityModel.Logging.6.16.0\lib\net45\Microsoft.IdentityModel.Logging.dll
diff --git a/FDC3WPFExample/packages.config b/FDC3WPFExample/packages.config
index d42ea0f..b20751f 100644
--- a/FDC3WPFExample/packages.config
+++ b/FDC3WPFExample/packages.config
@@ -1,7 +1,7 @@
-
+
diff --git a/MultiWindowExample/App.xaml.cs b/MultiWindowExample/App.xaml.cs
index a8fce64..b7c4b5d 100644
--- a/MultiWindowExample/App.xaml.cs
+++ b/MultiWindowExample/App.xaml.cs
@@ -110,6 +110,7 @@ public static void Main(string[] args)
application = new App();
application.InitializeComponent();
mutex.ReleaseMutex();
+ // Blocks main thread
application.Run();
// Allow single instance code to perform cleanup operations
diff --git a/MultiWindowExample/IIntegrateable.cs b/MultiWindowExample/IIntegrateable.cs
index fb4fdee..41e3abb 100644
--- a/MultiWindowExample/IIntegrateable.cs
+++ b/MultiWindowExample/IIntegrateable.cs
@@ -1,5 +1,4 @@
-using System.Windows;
-using ChartIQ.Finsemble;
+using ChartIQ.Finsemble;
namespace MultiWindowExample
{
@@ -7,11 +6,11 @@ namespace MultiWindowExample
/// Interface for windows that can be integrated with Finsemble.
///
interface IIntegratable
- {
+ {
///
/// Sets the instance of Finsemble to be used by this object.
///
/// The instance of Finsemble
void SetFinsemble(Finsemble fsbl);
- }
+ }
}
diff --git a/MultiWindowExample/MultiWindowExample.csproj b/MultiWindowExample/MultiWindowExample.csproj
index 107a0e7..cd80691 100644
--- a/MultiWindowExample/MultiWindowExample.csproj
+++ b/MultiWindowExample/MultiWindowExample.csproj
@@ -49,8 +49,8 @@
..\packages\DotNetZip.1.16.0\lib\net40\DotNetZip.dll
-
- ..\packages\Finsemble.8.9.3\lib\net452\Finsemble.dll
+
+ ..\packages\Finsemble.8.11.0\lib\net452\Finsemble.dll
..\packages\Microsoft.IdentityModel.Logging.6.16.0\lib\net45\Microsoft.IdentityModel.Logging.dll
diff --git a/MultiWindowExample/SingleInstance.cs b/MultiWindowExample/SingleInstance.cs
index c63b0aa..1b9a6e4 100644
--- a/MultiWindowExample/SingleInstance.cs
+++ b/MultiWindowExample/SingleInstance.cs
@@ -12,6 +12,7 @@
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
+using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.Remoting;
@@ -188,7 +189,6 @@ public static string[] CommandLineToArgvW(string cmdLine)
// Assert.AreEqual(IntPtr.Zero, p);
}
}
-
}
public interface ISingleInstanceApp
@@ -250,18 +250,6 @@ public static class SingleInstance
#endregion
- #region Public Properties
-
- ///
- /// Gets list of command line arguments for the application.
- ///
- public static IList CommandLineArgs
- {
- get { return commandLineArgs; }
- }
-
- #endregion
-
#region Public Methods
///
@@ -274,19 +262,19 @@ public static bool InitializeAsFirstInstance(string uniqueName)
commandLineArgs = GetCommandLineArgs(uniqueName);
// Build unique application Id and the IPC channel name.
- string applicationIdentifier = uniqueName + Environment.UserName;
+ string applicationIdentifier = $"{uniqueName}{Environment.UserName}";
- string channelName = String.Concat(applicationIdentifier, Delimiter, ChannelNameSuffix);
+ string channelName = string.Concat(applicationIdentifier, Delimiter, ChannelNameSuffix);
// Create mutex based on unique application Id to check if this is the first instance of the application.
- bool firstInstance;
- singleInstanceMutex = new Mutex(true, applicationIdentifier, out firstInstance);
+ singleInstanceMutex = new Mutex(true, applicationIdentifier, out bool firstInstance);
if (firstInstance)
{
CreateRemoteService(channelName);
}
else
{
+ Trace.TraceInformation($"Send message to the Main instance: {string.Join(", ", commandLineArgs)}");
SignalFirstInstance(channelName, commandLineArgs);
}
@@ -298,11 +286,8 @@ public static bool InitializeAsFirstInstance(string uniqueName)
///
public static void Cleanup()
{
- if (singleInstanceMutex != null)
- {
- singleInstanceMutex.Close();
- singleInstanceMutex = null;
- }
+ singleInstanceMutex?.Close();
+ singleInstanceMutex = null;
if (channel != null)
{
@@ -321,7 +306,7 @@ public static void Cleanup()
/// List of command line arg strings.
private static IList GetCommandLineArgs(string uniqueApplicationName)
{
- string[] args = null;
+ string[] args = new string[] { };
if (AppDomain.CurrentDomain.ActivationContext == null)
{
// The application was not clickonce deployed, get args from standard API's
@@ -333,7 +318,7 @@ private static IList GetCommandLineArgs(string uniqueApplicationName)
// Clickonce deployed apps cannot recieve traditional commandline arguments
// As a workaround commandline arguments can be written to a shared location before
// the app is launched and the app can obtain its commandline arguments from the
- // shared location
+ // shared location
string appFolderPath = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), uniqueApplicationName);
@@ -349,18 +334,14 @@ private static IList GetCommandLineArgs(string uniqueApplicationName)
File.Delete(cmdLinePath);
}
- catch (IOException)
+ catch (IOException ex)
{
+ Trace.TraceError($"Failed to read file: {cmdLinePath}. The error: {ex.Message}");
}
}
}
- if (args == null)
- {
- args = new string[] { };
- }
-
- return new List(args);
+ return args;
}
///
@@ -371,11 +352,12 @@ private static void CreateRemoteService(string channelName)
{
BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider();
serverProvider.TypeFilterLevel = TypeFilterLevel.Full;
- IDictionary props = new Dictionary();
-
- props["name"] = channelName;
- props["portName"] = channelName;
- props["exclusiveAddressUse"] = "false";
+ IDictionary props = new Dictionary()
+ {
+ { "name", channelName },
+ {"portName", channelName },
+ { "exclusiveAddressUse", "false"}
+ };
// Create the IPC Server channel with the channel properties
channel = new IpcServerChannel(props, serverProvider);
@@ -402,19 +384,16 @@ private static void SignalFirstInstance(string channelName, IList args)
IpcClientChannel secondInstanceChannel = new IpcClientChannel();
ChannelServices.RegisterChannel(secondInstanceChannel, true);
- string remotingServiceUrl = IpcProtocol + channelName + "/" + RemoteServiceName;
+ string remotingServiceUrl = $"{IpcProtocol}{channelName}/{RemoteServiceName}";
// Obtain a reference to the remoting service exposed by the server i.e the first instance of the application
- IPCRemoteService firstInstanceRemoteServiceReference = (IPCRemoteService)RemotingServices.Connect(typeof(IPCRemoteService), remotingServiceUrl);
+ var firstInstanceRemoteServiceReference = RemotingServices.Connect(typeof(IPCRemoteService), remotingServiceUrl) as IPCRemoteService;
// Check that the remote service exists, in some cases the first instance may not yet have created one, in which case
// the second instance should just exit
- if (firstInstanceRemoteServiceReference != null)
- {
- // Invoke a method of the remote service exposed by the first instance passing on the command line
- // arguments and causing the first instance to activate itself
- firstInstanceRemoteServiceReference.InvokeFirstInstance(args);
- }
+ // Invoke a method of the remote service exposed by the first instance passing on the command line
+ // arguments and causing the first instance to activate itself
+ firstInstanceRemoteServiceReference?.InvokeFirstInstance(args);
}
///
@@ -425,8 +404,7 @@ private static void SignalFirstInstance(string channelName, IList args)
private static object ActivateFirstInstanceCallback(object arg)
{
// Get command line args to be passed to first instance
- IList args = arg as IList;
- ActivateFirstInstance(args);
+ ActivateFirstInstance(arg as IList);
return null;
}
diff --git a/MultiWindowExample/packages.config b/MultiWindowExample/packages.config
index 1ff02da..c130ec9 100644
--- a/MultiWindowExample/packages.config
+++ b/MultiWindowExample/packages.config
@@ -1,7 +1,7 @@
-
+
diff --git a/WPFExample/MainWindow.xaml.cs b/WPFExample/MainWindow.xaml.cs
index 178a6c9..cb8bbf7 100644
--- a/WPFExample/MainWindow.xaml.cs
+++ b/WPFExample/MainWindow.xaml.cs
@@ -12,6 +12,8 @@
using ChartIQ.Finsemble.FDC3.Types;
using Microsoft.IdentityModel.Tokens;
using System.Windows.Interop;
+using ChartIQ.Finsemble.FDC3.Interfaces;
+using System.Diagnostics;
namespace WPFExample
{
@@ -60,7 +62,16 @@ private async void SpawnComponent_Click(object sender, RoutedEventArgs e)
}
});
- var appId = await FSBL.FDC3Client.DesktopAgentClient.Open(componentName, context);
+ // Check if the component able to receive the context
+ var contextToSend = await ShouldSendContextToComponent(context, componentName) ? context : null;
+ try
+ {
+ var appId = await FSBL.FDC3Client.DesktopAgentClient.Open(componentName, contextToSend);
+ }
+ catch(Exception ex)
+ {
+ Trace.TraceError($"Failed to open the app: {ex.Message}");
+ }
//Intent
//var context = new Context(new JObject
@@ -371,6 +382,18 @@ await FSBL.getDispatcher().Invoke(async delegate //main thread
//});
WindowReady?.Invoke(this, EventArgs.Empty);
+
+ _ = Task.Run(async () =>
+ {
+ await Task.Delay(5000);
+ Dispatcher.Invoke(delegate
+ {
+ Width = 1600;
+ Height = 60;
+ Top = 200;
+ Left = 200;
+ });
+ });
}
private void Logger_OnLog(object sender, JObject e)
@@ -553,5 +576,24 @@ private void Subscribe_to_pubsub()
}
});
}
+
+ ///
+ /// check if the component able to receive the context
+ ///
+ private async Task ShouldSendContextToComponent(IContext context, string componentName)
+ {
+ var componentConfig = (await FSBL.ConfigClient.Get(new[] { "finsemble", "components", componentName }))?.response;
+ var intents = componentConfig?["appConfig"]?["interop"]?["intents"]?["listensFor"]?.Children();
+
+ foreach (var intent in intents)
+ {
+ if (intent?.First?["contexts"]?.ToString().Contains(context.Type) == true)
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
}
}
diff --git a/WPFExample/WPFExample.csproj b/WPFExample/WPFExample.csproj
index 248a2fc..b7222f2 100644
--- a/WPFExample/WPFExample.csproj
+++ b/WPFExample/WPFExample.csproj
@@ -49,8 +49,8 @@
..\packages\DotNetZip.1.16.0\lib\net40\DotNetZip.dll
-
- ..\packages\Finsemble.8.9.3\lib\net452\Finsemble.dll
+
+ ..\packages\Finsemble.8.11.0\lib\net452\Finsemble.dll
..\packages\Microsoft.IdentityModel.Logging.6.16.0\lib\net45\Microsoft.IdentityModel.Logging.dll
diff --git a/WPFExample/packages.config b/WPFExample/packages.config
index d42ea0f..b20751f 100644
--- a/WPFExample/packages.config
+++ b/WPFExample/packages.config
@@ -1,7 +1,7 @@
-
+
diff --git a/WPFExampleCore/MainWindow.xaml.cs b/WPFExampleCore/MainWindow.xaml.cs
index 861c2e2..2e3606e 100644
--- a/WPFExampleCore/MainWindow.xaml.cs
+++ b/WPFExampleCore/MainWindow.xaml.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Interop;
@@ -405,7 +406,16 @@ private async void SpawnComponent_Click(object sender, RoutedEventArgs e)
}
});
- var appId = await FSBL.Clients.Fdc3Client.DesktopAgentClient.Open(componentName, context);
+ // Check if the component able to receive the context
+ var contextToSend = await ShouldSendContextToComponent(context, componentName) ? context : null;
+ try
+ {
+ var appId = await FSBL.Clients.Fdc3Client.DesktopAgentClient.Open(componentName, contextToSend);
+ }
+ catch (Exception ex)
+ {
+ Trace.TraceError($"Failed to open the app: {ex.Message}");
+ }
}
else
{
@@ -414,6 +424,22 @@ private async void SpawnComponent_Click(object sender, RoutedEventArgs e)
}
}
+ private async Task ShouldSendContextToComponent(Context context, string componentName)
+ {
+ var componentConfig = (await FSBL.Clients.ConfigClient.Get(new[] { "finsemble", "components", componentName }))?.response;
+ var intents = componentConfig?["appConfig"]?["interop"]?["intents"]?["listensFor"]?.Children();
+
+ foreach (var intent in intents)
+ {
+ if (intent?.First?["contexts"]?.ToString().Contains(context.Type) == true)
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
private void Send_Click(object sender, RoutedEventArgs e)
{
if (FSBL.Clients.Fdc3Client is object)
diff --git a/WPFExampleCore/WPFExampleCore.csproj b/WPFExampleCore/WPFExampleCore.csproj
index 2d02edc..abae539 100644
--- a/WPFExampleCore/WPFExampleCore.csproj
+++ b/WPFExampleCore/WPFExampleCore.csproj
@@ -29,7 +29,7 @@
-
+
diff --git a/WPFMultiWindowExampleCore/WPFMultiWindowExampleCore.csproj b/WPFMultiWindowExampleCore/WPFMultiWindowExampleCore.csproj
index b586bd9..8f98732 100644
--- a/WPFMultiWindowExampleCore/WPFMultiWindowExampleCore.csproj
+++ b/WPFMultiWindowExampleCore/WPFMultiWindowExampleCore.csproj
@@ -26,7 +26,7 @@
-
+
diff --git a/WindowlessExample.Core/WindowlessExample.Core.csproj b/WindowlessExample.Core/WindowlessExample.Core.csproj
index 329a8b0..dbcf7eb 100644
--- a/WindowlessExample.Core/WindowlessExample.Core.csproj
+++ b/WindowlessExample.Core/WindowlessExample.Core.csproj
@@ -1,4 +1,4 @@
-
+
WinExe
@@ -24,7 +24,7 @@
-
+
diff --git a/WindowlessExample/WindowlessExample.csproj b/WindowlessExample/WindowlessExample.csproj
index f803fc0..aa149e1 100644
--- a/WindowlessExample/WindowlessExample.csproj
+++ b/WindowlessExample/WindowlessExample.csproj
@@ -46,8 +46,8 @@
bin\x64\Release\
-
- ..\packages\Finsemble.8.9.3\lib\net452\Finsemble.dll
+
+ ..\packages\Finsemble.8.11.0\lib\net452\Finsemble.dll
diff --git a/WindowlessExample/packages.config b/WindowlessExample/packages.config
index 4c81ed6..865a7a0 100644
--- a/WindowlessExample/packages.config
+++ b/WindowlessExample/packages.config
@@ -1,6 +1,6 @@
-
+
diff --git a/WinformExample/FormExample.cs b/WinformExample/FormExample.cs
index bf4b9a8..85eb8ae 100644
--- a/WinformExample/FormExample.cs
+++ b/WinformExample/FormExample.cs
@@ -14,6 +14,7 @@
using ChartIQ.Finsemble.FDC3.Types;
using Microsoft.IdentityModel.Tokens;
using ChartIQ.Finsemble.FDC3.Interfaces;
+using System.Diagnostics;
namespace WinformExample
{
@@ -138,7 +139,10 @@ private async void FinsembleConnected(object sender, EventArgs e)
// Example for getting Spawnable component list
- FSBL.ConfigClient.GetValue(new JObject { ["field"] = "finsemble.components" }, HandleComponentsList);
+ var response = await FSBL.ConfigClient.Get(new[] { "finsemble", "components" });
+ HandleComponentsList(response);
+
+ // FSBL.PublishReady();
}
private void HandleContext(Context context, IContextMetadata metadata)
@@ -457,35 +461,32 @@ private void HandleLinkerData(object sender, FinsembleEventArgs response)
}));
}
- private void HandleComponentsList(Object sender, FinsembleEventArgs response)
+ private void HandleComponentsList(FinsembleEventArgs response)
{
- this.Invoke(new Action(() =>
+ if (response.error != null)
{
- if (response.error != null)
- {
- FSBL.Logger.Error(new JToken[] { "Error when receiving spawnable component list: ", response.error.ToString() });
- }
- else if (response.response != null)
+ FSBL.Logger.Error(new JToken[] { "Error when receiving spawnable component list: ", response.error.ToString() });
+ }
+ else if (response.response != null)
+ {
+ var components = response.response as JObject;
+ foreach (var property in components?.Properties())
{
- var components = (JObject)response.response?["data"];
- foreach (var property in components?.Properties())
+ var launchableByUser = components?[property.Name]?["foreign"]?["components"]?["App Launcher"]?["launchableByUser"]?.ToObject();
+ if (launchableByUser == true)
{
- object value = components?[property.Name]?["foreign"]?["components"]?["App Launcher"]?["launchableByUser"];
- if ((value != null) && bool.Parse(value.ToString()))
+ ComponentDropDown.Invoke(new Action(() =>
{
- Dispatcher.CurrentDispatcher.Invoke(() =>
+ //elimination of duplicate names of components after Finsemble restart
+ if (!ComponentDropDown.Items.Contains(property.Name))
{
- //elimination of duplicate names of components after Finsemble restart
- if (!ComponentDropDown.Items.Contains(property.Name))
- {
- ComponentDropDown.Items.Add(property.Name);
- ComponentDropDown.SelectedIndex = 0;
- }
- });
- }
+ ComponentDropDown.Items.Add(property.Name);
+ ComponentDropDown.SelectedIndex = 0;
+ }
+ }));
}
}
- }));
+ }
}
private void handleKeyPresses(object sender, System.Windows.Forms.KeyPressEventArgs e)
@@ -531,7 +532,16 @@ private async void LaunchButton_Click(object sender, EventArgs e)
}
});
- var appId = await FSBL.FDC3Client.DesktopAgentClient.Open(componentName, context);
+ // Check if the component able to receive the context
+ var contextToSend = await ShouldSendContextToComponent(context, componentName) ? context : null;
+ try
+ {
+ var appId = await FSBL.FDC3Client.DesktopAgentClient.Open(componentName, contextToSend);
+ }
+ catch (Exception ex)
+ {
+ Trace.TraceError($"Failed to open the app: {ex.Message}");
+ }
}
else
{
@@ -539,6 +549,22 @@ private async void LaunchButton_Click(object sender, EventArgs e)
}
}
+ private async Task ShouldSendContextToComponent(Context context, string componentName)
+ {
+ var componentConfig = (await FSBL.ConfigClient.Get(new[] { "finsemble", "components", componentName }))?.response;
+ var intents = componentConfig?["appConfig"]?["interop"]?["intents"]?["listensFor"]?.Children();
+
+ foreach (var intent in intents)
+ {
+ if (intent?.First?["contexts"]?.ToString().Contains(context.Type) == true)
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
private void LinkerButton_Click(object sender, EventArgs e)
{
if (FSBL.LinkerClient != null)
diff --git a/WinformExample/WinformExample.csproj b/WinformExample/WinformExample.csproj
index 7137901..050be6d 100644
--- a/WinformExample/WinformExample.csproj
+++ b/WinformExample/WinformExample.csproj
@@ -50,8 +50,8 @@
..\packages\DotNetZip.1.16.0\lib\net40\DotNetZip.dll
-
- ..\packages\Finsemble.8.9.3\lib\net452\Finsemble.dll
+
+ ..\packages\Finsemble.8.11.0\lib\net452\Finsemble.dll
..\packages\Microsoft.IdentityModel.Logging.6.16.0\lib\net45\Microsoft.IdentityModel.Logging.dll
diff --git a/WinformExample/packages.config b/WinformExample/packages.config
index f364b7b..f3e0ed6 100644
--- a/WinformExample/packages.config
+++ b/WinformExample/packages.config
@@ -1,7 +1,7 @@
-
+
diff --git a/WinformExampleCore/MainForm.cs b/WinformExampleCore/MainForm.cs
index 4a980a5..e97b404 100644
--- a/WinformExampleCore/MainForm.cs
+++ b/WinformExampleCore/MainForm.cs
@@ -11,6 +11,7 @@
using System.Diagnostics;
using System.Drawing;
using System.Linq;
+using System.Threading.Tasks;
using System.Windows.Forms;
namespace WinformExampleCore
@@ -522,9 +523,11 @@ private async void LaunchButton_Click(object sender, EventArgs e)
}
});
+ // Check if the component able to receive the context
+ var contextToSend = await ShouldSendContextToComponent(context, componentName) ? context : null;
try
{
- var appIdentifier = await _bridge.Clients.Fdc3Client.DesktopAgentClient.Open(componentName, context);
+ var appId = await _bridge.Clients.Fdc3Client.DesktopAgentClient.Open(componentName, contextToSend);
}
catch (Exception ex)
{
@@ -532,6 +535,22 @@ private async void LaunchButton_Click(object sender, EventArgs e)
}
}
+ private async Task ShouldSendContextToComponent(Context context, string componentName)
+ {
+ var componentConfig = (await _bridge.Clients.ConfigClient.Get(new[] { "finsemble", "components", componentName }))?.response;
+ var intents = componentConfig?["appConfig"]?["interop"]?["intents"]?["listensFor"]?.Children();
+
+ foreach (var intent in intents)
+ {
+ if (intent?.First?["contexts"]?.ToString().Contains(context.Type) == true)
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
private void DragNDropEmittingButton_MouseDown(object sender, MouseEventArgs e)
{
ScrimLabel.BringToFront();
diff --git a/WinformExampleCore/WinformExampleCore.csproj b/WinformExampleCore/WinformExampleCore.csproj
index 22e400e..5f0453d 100644
--- a/WinformExampleCore/WinformExampleCore.csproj
+++ b/WinformExampleCore/WinformExampleCore.csproj
@@ -39,7 +39,7 @@
-
+
diff --git a/WinformMultiWindowExample/WinformMultiWindowExample.csproj b/WinformMultiWindowExample/WinformMultiWindowExample.csproj
index 20555f2..38d2e04 100644
--- a/WinformMultiWindowExample/WinformMultiWindowExample.csproj
+++ b/WinformMultiWindowExample/WinformMultiWindowExample.csproj
@@ -50,8 +50,8 @@
..\packages\DotNetZip.1.16.0\lib\net40\DotNetZip.dll
-
- ..\packages\Finsemble.8.9.3\lib\net452\Finsemble.dll
+
+ ..\packages\Finsemble.8.11.0\lib\net452\Finsemble.dll
..\packages\Microsoft.IdentityModel.Logging.6.16.0\lib\net45\Microsoft.IdentityModel.Logging.dll
diff --git a/WinformMultiWindowExample/packages.config b/WinformMultiWindowExample/packages.config
index 480ba5d..ec81177 100644
--- a/WinformMultiWindowExample/packages.config
+++ b/WinformMultiWindowExample/packages.config
@@ -1,7 +1,7 @@
-
+
diff --git a/WinformMultiWindowExampleCore/WinformMultiWindowExampleCore.csproj b/WinformMultiWindowExampleCore/WinformMultiWindowExampleCore.csproj
index 0995c51..fedc648 100644
--- a/WinformMultiWindowExampleCore/WinformMultiWindowExampleCore.csproj
+++ b/WinformMultiWindowExampleCore/WinformMultiWindowExampleCore.csproj
@@ -25,7 +25,7 @@
-
+