Skip to content

Commit

Permalink
Load context support for net core
Browse files Browse the repository at this point in the history
  • Loading branch information
Nice3point committed Sep 16, 2024
1 parent e7e811f commit 5a9d9a6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
10 changes: 5 additions & 5 deletions source/RevitLookup/Models/ModuleInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ namespace RevitLookup.Models;

public sealed class ModuleInfo
{
public required string Name { get; set; }
public required string Path { get; set; }
public required int Order { get; set; }
public required string Version { get; set; }
public required string Domain { get; set; }
public required string Name { get; init; }
public required string Path { get; init; }
public required int Order { get; init; }
public required string Version { get; init; }
public required string Container { get; init; }
}
10 changes: 8 additions & 2 deletions source/RevitLookup/ViewModels/Dialogs/ModulesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.

#if NETCOREAPP
using System.Runtime.Loader;
#endif
using RevitLookup.Models;

namespace RevitLookup.ViewModels.Dialogs;
Expand All @@ -35,7 +38,6 @@ public ModulesViewModel()

private void Initialize()
{
var domain = AppDomain.CurrentDomain;
var assemblies = AppDomain.CurrentDomain.GetAssemblies();
Modules = new List<ModuleInfo>(assemblies.Length);

Expand All @@ -49,7 +51,11 @@ private void Initialize()
Path = assembly.IsDynamic ? string.Empty : assembly.Location,
Order = i + 1,
Version = assemblyName.Version is null ? string.Empty : assemblyName.Version.ToString(),
Domain = domain.FriendlyName
#if NETCOREAPP
Container = AssemblyLoadContext.GetLoadContext(assembly)?.Name
#else
Container = AppDomain.CurrentDomain.FriendlyName
#endif
};

Modules.Add(module);
Expand Down
8 changes: 4 additions & 4 deletions source/RevitLookup/Views/Dialogs/ModulesDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn
Width="2*"
Header="Domain">
x:Name="ContainerColumn"
Width="2*">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock
Text="{Binding Domain}"
ToolTip="{Binding Domain}">
Text="{Binding Container}"
ToolTip="{Binding Container}">
</TextBlock>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
Expand Down
6 changes: 6 additions & 0 deletions source/RevitLookup/Views/Dialogs/ModulesDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ public ModulesDialog(IServiceProvider serviceProvider)
_serviceProvider = serviceProvider;
DataContext = new ModulesViewModel();
InitializeComponent();

#if NETCOREAPP
ContainerColumn.Header = "Load context";
#else
ContainerColumn.Header = "Domain";
#endif
}

public async Task ShowAsync()
Expand Down

0 comments on commit 5a9d9a6

Please sign in to comment.