LoadClientAssemblies adds satellite assemblies

This commit is contained in:
hishamco 2020-09-29 18:28:02 +03:00
parent ec73c958c9
commit accf947afd
3 changed files with 26 additions and 18 deletions

View File

@ -1,19 +1,18 @@
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.DependencyInjection;
using System.Threading.Tasks;
using Oqtane.Services;
using System.Reflection;
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Json;
using Oqtane.Modules;
using Oqtane.Shared;
using Oqtane.Providers;
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components.Authorization;
using System.IO.Compression;
using System.IO;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Oqtane.Modules;
using Oqtane.Providers;
using Oqtane.Shared;
using Oqtane.Services;
namespace Oqtane.Client
{
@ -101,8 +100,8 @@ namespace Oqtane.Client
// asemblies and debug symbols are packaged in a zip file
using (ZipArchive archive = new ZipArchive(new MemoryStream(zip)))
{
Dictionary<string, byte[]> dlls = new Dictionary<string, byte[]>();
Dictionary<string, byte[]> pdbs = new Dictionary<string, byte[]>();
var dlls = new Dictionary<string, byte[]>();
var pdbs = new Dictionary<string, byte[]>();
foreach (ZipArchiveEntry entry in archive.Entries)
{
@ -115,7 +114,15 @@ namespace Oqtane.Client
switch (Path.GetExtension(entry.Name))
{
case ".dll":
// Loads the stallite assemblies early
if (entry.Name.EndsWith(Constants.StalliteAssemblyExtension))
{
Assembly.Load(entry.Name);
}
else
{
dlls.Add(entry.Name, file);
}
break;
case ".pdb":
pdbs.Add(entry.Name, file);

View File

@ -8,6 +8,7 @@ using Oqtane.Infrastructure;
using Oqtane.Infrastructure.Localization;
using Oqtane.Modules;
using Oqtane.Services;
using Oqtane.Shared;
using Oqtane.UI;
// ReSharper disable once CheckNamespace
@ -15,8 +16,6 @@ namespace Microsoft.Extensions.DependencyInjection
{
public static class OqtaneServiceCollectionExtensions
{
private static readonly string StalliteAssemblyExtension = ".resources.dll";
public static IServiceCollection AddOqtane(this IServiceCollection services, Runtime runtime)
{
LoadAssemblies();
@ -138,7 +137,7 @@ namespace Microsoft.Extensions.DependencyInjection
foreach (var culture in LocalizationSettings.SupportedCultures)
{
var assembliesFolder = new DirectoryInfo(Path.Combine(assemblyPath, culture));
foreach (var assemblyFile in assembliesFolder.EnumerateFiles(StalliteAssemblyExtension))
foreach (var assemblyFile in assembliesFolder.EnumerateFiles(Constants.StalliteAssemblyExtension))
{
AssemblyName assemblyName;
try

View File

@ -57,5 +57,7 @@ namespace Oqtane.Shared
(Char) 28, (Char) 29, (Char) 30, (Char) 31, ':', '*', '?', '\\', '/'
};
public static readonly string[] InvalidFileNameEndingChars = { ".", " " };
public static readonly string StalliteAssemblyExtension = ".resources.dll";
}
}