Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ private void Application_Startup(object sender, StartupEventArgs e)
});

serviceCollection.AddMessageRouterMessagingAdapter();

serviceCollection.AddFdc3DesktopAgentClient();
}
catch
catch(Exception exception)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an unnecessary addition

{
// MessageRouter couldn't be initialized, text will be displayed
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ See the License for the specific language governing permissions and limitations
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\fdc3\dotnet\DesktopAgent.Client\src\MorganStanley.ComposeUI.Fdc3.DesktopAgent.Client\MorganStanley.ComposeUI.Fdc3.DesktopAgent.Client.csproj" />
<ProjectReference Include="..\..\..\src\messaging\dotnet\src\Client\MorganStanley.ComposeUI.Messaging.Client.csproj" />
<ProjectReference Include="..\..\..\src\messaging\dotnet\src\MessageRouterAdapter\MorganStanley.ComposeUI.Messaging.MessageRouterAdapter.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
using MorganStanley.ComposeUI.Messaging;
using MorganStanley.ComposeUI.Messaging.Abstractions;
using MorganStanley.ComposeUI.Messaging.Client.WebSocket;
using System;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Threading;
using Finos.Fdc3;
using MorganStanley.ComposeUI.Fdc3.DesktopAgent.Shared.Protocol;

namespace DiagnosticsExample;

Expand All @@ -28,9 +27,7 @@ namespace DiagnosticsExample;
/// </summary>
public partial class MainWindow : Window
{
private IMessaging? _messageRouter;


private readonly IMessaging? _messaging;

public string DiagnosticsText
{
Expand All @@ -42,12 +39,15 @@ public string DiagnosticsText
public static readonly DependencyProperty DiagnosticsTextProperty =
DependencyProperty.Register("DiagnosticsText", typeof(string), typeof(MainWindow), new PropertyMetadata(string.Empty));

private readonly IDesktopAgent _desktopAgent;


public MainWindow()
{
InitializeComponent();
_messageRouter = ((App)Application.Current).ServiceProvider.GetService<IMessaging>();

_messaging = ((App)Application.Current).ServiceProvider.GetService<IMessaging>();
_desktopAgent = ((App)Application.Current).ServiceProvider.GetService<IDesktopAgent>() ?? throw new NullReferenceException();
}

private void Window_Loaded(object sender, RoutedEventArgs e)
Expand All @@ -62,7 +62,7 @@ private void Window_Loaded(object sender, RoutedEventArgs e)

try
{
if (_messageRouter != null)
if (_messaging != null)
{
Task.Run(LogDiagnostics);
}
Expand All @@ -79,11 +79,19 @@ private void Window_Loaded(object sender, RoutedEventArgs e)

private async Task LogDiagnostics()
{
var diag = await _messageRouter!.InvokeJsonServiceAsync<DiagnosticInfo>("Diagnostics", new JsonSerializerOptions { WriteIndented = true });
var diag = await _messaging!.InvokeJsonServiceAsync<DiagnosticInfo>("Diagnostics", new JsonSerializerOptions { WriteIndented = true });

if (diag == null)
{
return;
}

await Dispatcher.InvokeAsync(() => DiagnosticsText += diag.ToString());

var result =
await _desktopAgent.GetAppMetadata(new MorganStanley.ComposeUI.Fdc3.DesktopAgent.Shared.Protocol.AppIdentifier()
{ AppId = "WPFExample" });

await Dispatcher.InvokeAsync(() => DiagnosticsText += "\n" + result.Description);
}
}
37 changes: 37 additions & 0 deletions examples/fdc3-appdirectory/apps-with-intents.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,42 @@
{
"applications": [
{
"appId": "WPFExample",
"name": "WPF",
"type": "native",
"description": "This is an example WPF application",
"details": {
"path": "..\\..\\..\\..\\..\\..\\..\\..\\examples\\dotnet-diagnostics\\DiagnosticsExample\\bin\\Debug\\net8.0-windows\\DiagnosticsExample.exe"
},
"hostManifests": {
"sail": { "inject-api": "2.0" },
"ComposeUI": {
"initialModulePosition": "Floating",
"width": 506.2,
"height": 303.11,
"coordinates": {
"x": 89.5,
"y": 45.1
},
"environmentVariables": {
"CUSTOM_GREETINGS": "Hello ComposeUI!"
}
}
},
"icons": [
{
"src": "https://www.morganstanley.com/etc/designs/msdotcom/image/favicon-96x96.png",
"size": "10x10",
"type": "image/png"
}
],
"interop": {
"intents": {
"listensFor": {
}
}
}
},
{
"appId": "Morgan Stanley",
"name": "Morgan Stanley",
Expand Down
4 changes: 4 additions & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<Project>
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props, $(MSBuildThisFileDirectory)..))" />

</Project>
4 changes: 4 additions & 0 deletions src/fdc3/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<Project>
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props, $(MSBuildThisFileDirectory)..))" />

</Project>
4 changes: 2 additions & 2 deletions src/fdc3/dotnet/AppDirectory/AppDirectory.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.7.34024.191
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MorganStanley.ComposeUI.AppDirectory", "src\MorganStanley.ComposeUI.AppDirectory\MorganStanley.ComposeUI.AppDirectory.csproj", "{4B8CA047-2023-4E1A-BD73-85F7EB1D56B3}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MorganStanley.ComposeUI.Fdc3.AppDirectory", "src\MorganStanley.ComposeUI.Fdc3.AppDirectory\MorganStanley.ComposeUI.Fdc3.AppDirectory.csproj", "{4B8CA047-2023-4E1A-BD73-85F7EB1D56B3}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{9E52D00C-AABB-4579-8724-6CC7049F021E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MorganStanley.ComposeUI.AppDirectory.Tests", "test\MorganStanley.ComposeUI.AppDirectory.Tests\MorganStanley.ComposeUI.AppDirectory.Tests.csproj", "{EAA7B5A8-FD08-4E2F-809B-6CBD489714C1}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MorganStanley.ComposeUI.Fdc3.AppDirectory.Tests", "test\MorganStanley.ComposeUI.Fdc3.AppDirectory.Tests\MorganStanley.ComposeUI.Fdc3.AppDirectory.Tests.csproj", "{EAA7B5A8-FD08-4E2F-809B-6CBD489714C1}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this affect nuget package names?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "lib", "lib", "{62C29BA4-0D3B-4764-A898-38F29FF5C36C}"
EndProject
Expand Down
2 changes: 1 addition & 1 deletion src/fdc3/dotnet/AppDirectory/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
Install the NuGet package:

```shell
dotnet package add MorganStanley.ComposeUI.Fdc3.AppDirectory
dotnet add package MorganStanley.ComposeUI.Fdc3.AppDirectory
```

Or via the NuGet Package Manager:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public async Task<IModuleManifest> GetManifest(string moduleId)
private IModuleManifest GetManifest(Fdc3App app) => app.Type switch
{
AppType.Web => new Fdc3WebModuleManifest(app, _hostManifestMapper),
AppType.Native => new Fdc3NativeModuleManifest(app, _hostManifestMapper),
_ => throw new NotSupportedException($"Unsupported module type: {app.Type}"),
};

Expand Down Expand Up @@ -107,4 +108,51 @@ public async Task<IEnumerable<IModuleManifest>> GetAllManifests()

return apps.Select(GetManifest);
}


private class Fdc3NativeModuleManifest : IModuleManifest<NativeManifestDetails>
{
private readonly IHostManifestMapper? _hostManifestMapper;

public Fdc3NativeModuleManifest(Fdc3App app, IHostManifestMapper hostManifestMapper)
{
if (app.Type != AppType.Native)
{
throw new ArgumentException("The provided app is not a native app.", nameof(app));
}

_hostManifestMapper = hostManifestMapper;

Id = app.AppId;
Name = app.Name ?? app.Title;

Tags = app.Categories?.ToArray() ?? [];
AdditionalProperties = [];

var details = _hostManifestMapper?.MapModuleDetails(app);

if (details is NativeManifestDetails nativeManifestDetails)
{
Details = nativeManifestDetails;
}
else
{
var iconSrc = app.Icons?.FirstOrDefault()?.Src;
var path = new Uri(((NativeAppDetails) app.Details).Path, UriKind.Absolute);

Details = new NativeManifestDetails
{
Path = path,
Icon = iconSrc != null ? new Uri(iconSrc, UriKind.Absolute) : null,
};
}
}

public string Id { get; init; }
public string Name { get; init; }
public string ModuleType => ModuleLoader.ModuleType.Native;
public string[] Tags { get; init; }
public Dictionary<string, string> AdditionalProperties { get; init; }
public NativeManifestDetails Details { get; init; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

<ItemGroup>
<ProjectReference Include="..\..\..\..\..\shared\dotnet\tests\TestUtils\MorganStanley.ComposeUI.Testing\MorganStanley.ComposeUI.Testing.csproj" />
<ProjectReference Include="..\..\src\MorganStanley.ComposeUI.AppDirectory\MorganStanley.ComposeUI.AppDirectory.csproj" />
<ProjectReference Include="..\..\src\MorganStanley.ComposeUI.Fdc3.AppDirectory\MorganStanley.ComposeUI.Fdc3.AppDirectory.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading
Loading