diff --git a/src/AbpDesk/AbpDesk.MongoBlog/AbpDesk/Blogging/AbpDeskMongoBlogModule.cs b/src/AbpDesk/AbpDesk.MongoBlog/AbpDesk/Blogging/AbpDeskMongoBlogModule.cs index 21dc026329..a6ef043fa5 100644 --- a/src/AbpDesk/AbpDesk.MongoBlog/AbpDesk/Blogging/AbpDeskMongoBlogModule.cs +++ b/src/AbpDesk/AbpDesk.MongoBlog/AbpDesk/Blogging/AbpDeskMongoBlogModule.cs @@ -28,7 +28,6 @@ namespace AbpDesk.Blogging { options.FileSets.Add( new EmbeddedFileSet( - "/", GetType().Assembly, "" //TODO: This is not tested yet! ) diff --git a/src/AbpDesk/Web_PlugIns/AbpDesk.MongoBlog.dll b/src/AbpDesk/Web_PlugIns/AbpDesk.MongoBlog.dll index 6426ca7db2..c867134e44 100644 Binary files a/src/AbpDesk/Web_PlugIns/AbpDesk.MongoBlog.dll and b/src/AbpDesk/Web_PlugIns/AbpDesk.MongoBlog.dll differ diff --git a/src/Volo.Abp.Account.Web/AbpAccountWebModule.cs b/src/Volo.Abp.Account.Web/AbpAccountWebModule.cs index 7bf5db493e..304699a4e0 100644 --- a/src/Volo.Abp.Account.Web/AbpAccountWebModule.cs +++ b/src/Volo.Abp.Account.Web/AbpAccountWebModule.cs @@ -21,7 +21,6 @@ namespace Volo.Abp.Account.Web { options.FileSets.Add( new EmbeddedFileSet( - "/", GetType().Assembly, "Volo.Abp.Account.Web" ) diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/AbpAspNetCoreMvcUiBootstrapModule.cs b/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/AbpAspNetCoreMvcUiBootstrapModule.cs index 34ff1c562e..6f19cb75ef 100644 --- a/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/AbpAspNetCoreMvcUiBootstrapModule.cs +++ b/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/AbpAspNetCoreMvcUiBootstrapModule.cs @@ -19,7 +19,6 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap { options.FileSets.Add( new EmbeddedFileSet( - "/", GetType().Assembly, "Volo.Abp.AspNetCore.Mvc.UI.Bootstrap" ) diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI/AbpAspNetCoreMvcUiModule.cs b/src/Volo.Abp.AspNetCore.Mvc.UI/AbpAspNetCoreMvcUiModule.cs index 6832714944..b1ee0bb864 100644 --- a/src/Volo.Abp.AspNetCore.Mvc.UI/AbpAspNetCoreMvcUiModule.cs +++ b/src/Volo.Abp.AspNetCore.Mvc.UI/AbpAspNetCoreMvcUiModule.cs @@ -19,7 +19,6 @@ namespace Volo.Abp.AspNetCore.Mvc { options.FileSets.Add( new EmbeddedFileSet( - "/", GetType().Assembly, "Volo.Abp.AspNetCore.Mvc" ) diff --git a/src/Volo.Abp.Identity.Web/AbpIdentityWebModule.cs b/src/Volo.Abp.Identity.Web/AbpIdentityWebModule.cs index 9991a2dc9c..100abda25b 100644 --- a/src/Volo.Abp.Identity.Web/AbpIdentityWebModule.cs +++ b/src/Volo.Abp.Identity.Web/AbpIdentityWebModule.cs @@ -27,7 +27,6 @@ namespace Volo.Abp.Identity.Web { options.FileSets.Add( new EmbeddedFileSet( - "/", GetType().Assembly, "Volo.Abp.Identity.Web" ) diff --git a/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/Embedded/EmbeddedFileSet.cs b/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/Embedded/EmbeddedFileSet.cs index 26e93d499a..859c8821fd 100644 --- a/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/Embedded/EmbeddedFileSet.cs +++ b/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/Embedded/EmbeddedFileSet.cs @@ -3,23 +3,25 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; +using JetBrains.Annotations; using Microsoft.Extensions.FileProviders; namespace Volo.Abp.VirtualFileSystem.Embedded { public class EmbeddedFileSet : IVirtualFileSet { - public string RootPath { get; } - + [NotNull] public Assembly Assembly { get; } - public string ResourceNamespace { get; } + [CanBeNull] + public string BaseNamespace { get; } - public EmbeddedFileSet(string rootPath, Assembly assembly, string resourceNamespace) + public EmbeddedFileSet([NotNull] Assembly assembly, string baseNamespace) { - RootPath = rootPath.EnsureEndsWith('/'); + Check.NotNull(assembly, nameof(assembly)); + Assembly = assembly; - ResourceNamespace = resourceNamespace; + BaseNamespace = baseNamespace; } public void AddFiles(Dictionary files) @@ -28,12 +30,12 @@ namespace Volo.Abp.VirtualFileSystem.Embedded foreach (var resourcePath in Assembly.GetManifestResourceNames()) { - if (!resourcePath.StartsWith(ResourceNamespace)) + if (!BaseNamespace.IsNullOrEmpty() && !resourcePath.StartsWith(BaseNamespace)) { continue; } - var fullPath = RootPath + ConvertToRelativePath(resourcePath); + var fullPath = ConvertToRelativePath(resourcePath).EnsureStartsWith('/'); if (fullPath.Contains("/")) { @@ -92,7 +94,10 @@ namespace Volo.Abp.VirtualFileSystem.Embedded private string ConvertToRelativePath(string resourceName) { - resourceName = resourceName.Substring(ResourceNamespace.Length + 1); + if (!BaseNamespace.IsNullOrEmpty()) + { + resourceName = resourceName.Substring(BaseNamespace.Length + 1); + } var pathParts = resourceName.Split('.'); if (pathParts.Length <= 2) diff --git a/test/Volo.Abp.VirtualFileSystem.Tests/Volo/Abp/VirtualFileSystem/EmbeddedFileManager_Tests.cs b/test/Volo.Abp.VirtualFileSystem.Tests/Volo/Abp/VirtualFileSystem/EmbeddedFileManager_Tests.cs index b59fb510a0..abda04da2e 100644 --- a/test/Volo.Abp.VirtualFileSystem.Tests/Volo/Abp/VirtualFileSystem/EmbeddedFileManager_Tests.cs +++ b/test/Volo.Abp.VirtualFileSystem.Tests/Volo/Abp/VirtualFileSystem/EmbeddedFileManager_Tests.cs @@ -23,7 +23,7 @@ namespace Volo.Abp.VirtualFileSystem public void Should_Define_And_Get_Embedded_Resources() { //Act - var resource = _embeddedFileManager.GetFileInfo("/MyApp/MyResources/js/jquery-3.1.1.min.js"); + var resource = _embeddedFileManager.GetFileInfo("/js/jquery-3.1.1.min.js"); //Assert resource.ShouldNotBeNull(); @@ -44,7 +44,6 @@ namespace Volo.Abp.VirtualFileSystem { options.FileSets.Add( new EmbeddedFileSet( - "/MyApp/MyResources/", GetType().Assembly, "Volo.Abp.VirtualFileSystem.MyResources" )