add defensive logic to Oqtane.Maui for loading modules which have not declared all dependencies

This commit is contained in:
Shaun Walker 2023-03-14 20:37:42 -04:00
parent 0a30f2b7e8
commit 04c0b9d37d
2 changed files with 23 additions and 9 deletions

View File

@ -212,6 +212,8 @@ public static class MauiProgram
private static void RegisterModuleServices(Assembly assembly, IServiceCollection services)
{
// dynamically register module scoped services
try
{
var implementationTypes = assembly.GetInterfaces<IService>();
foreach (var implementationType in implementationTypes)
{
@ -222,8 +224,15 @@ public static class MauiProgram
}
}
}
catch
{
// could not interrogate assembly - likely missing dependencies
}
}
private static void RegisterClientStartups(Assembly assembly, IServiceCollection services)
{
try
{
var startUps = assembly.GetInstances<IClientStartup>();
foreach (var startup in startUps)
@ -231,4 +240,9 @@ public static class MauiProgram
startup.ConfigureServices(services);
}
}
catch
{
// could not interrogate assembly - likely missing dependencies
}
}
}

View File

@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks> -->
<!-- <TargetFrameworks>$(TargetFrameworks);net6.0-tizen</TargetFrameworks> -->
<OutputType>Exe</OutputType>
<Version>3.4.1</Version>