Browse Source

Fix bundling problem.

pull/1788/head
Halil İbrahim Kalkan 7 years ago
parent
commit
fab4784e45
  1. 6
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleManager.cs
  2. 6
      framework/src/Volo.Abp.VirtualFileSystem/Microsoft/Extensions/FileProviders/AbpFileInfoExtensions.cs
  3. 1
      framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/IDynamicFileManager.cs
  4. 8
      framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/InMemoryFileInfo.cs
  5. 11
      framework/test/Volo.Abp.VirtualFileSystem.Tests/Volo/Abp/VirtualFileSystem/DynamicFileProvider_Tests.cs

6
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleManager.cs

@ -139,11 +139,11 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling
DynamicFileProvider.AddOrUpdate(
new InMemoryFileInfo(
Encoding.UTF8.GetBytes(bundleResult.Content),
"/wwwroot/" + bundleRelativePath, //TODO: get rid of wwwroot!
Encoding.UTF8.GetBytes(bundleResult.Content),
fileName
)
);
)
);
}
protected virtual bool IsBundlingEnabled()

6
framework/src/Volo.Abp.VirtualFileSystem/Microsoft/Extensions/FileProviders/AbpFileInfoExtensions.cs

@ -3,6 +3,7 @@ using System.IO;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.VirtualFileSystem;
using Volo.Abp.VirtualFileSystem.Embedded;
namespace Microsoft.Extensions.FileProviders
@ -68,6 +69,11 @@ namespace Microsoft.Extensions.FileProviders
return embeddedFileInfo.VirtualPath;
}
if (fileInfo is InMemoryFileInfo inMemoryFileInfo)
{
return inMemoryFileInfo.DynamicPath;
}
return fileInfo.PhysicalPath;
}
}

1
framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/IDynamicFileManager.cs

@ -5,6 +5,7 @@ namespace Volo.Abp.VirtualFileSystem
public interface IDynamicFileProvider : IFileProvider
{
void AddOrUpdate(IFileInfo fileInfo);
bool Delete(string filePath);
}
}

8
framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/InMemoryFileInfo.cs

@ -10,7 +10,7 @@ namespace Volo.Abp.VirtualFileSystem
public long Length => _fileContent.Length;
public string PhysicalPath { get; }
public string PhysicalPath => null;
public string Name { get; }
@ -20,9 +20,11 @@ namespace Volo.Abp.VirtualFileSystem
private readonly byte[] _fileContent;
public InMemoryFileInfo(byte[] fileContent, string physicalPath, string name)
public string DynamicPath { get; }
public InMemoryFileInfo(string dynamicPath, byte[] fileContent, string name)
{
PhysicalPath = physicalPath;
DynamicPath = dynamicPath;
Name = name;
_fileContent = fileContent;
LastModified = DateTimeOffset.Now;

11
framework/test/Volo.Abp.VirtualFileSystem.Tests/Volo/Abp/VirtualFileSystem/DynamicFileProvider_Tests.cs

@ -1,5 +1,4 @@
using System;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Primitives;
using Shouldly;
@ -24,8 +23,8 @@ namespace Volo.Abp.VirtualFileSystem
_dynamicFileProvider.AddOrUpdate(
new InMemoryFileInfo(
fileContent.GetBytes(),
"/my-files/test.txt",
fileContent.GetBytes(),
"test.txt"
)
);
@ -42,8 +41,8 @@ namespace Volo.Abp.VirtualFileSystem
_dynamicFileProvider.AddOrUpdate(
new InMemoryFileInfo(
"Hello World".GetBytes(),
"/my-files/test.txt",
"Hello World".GetBytes(),
"test.txt"
)
);
@ -60,8 +59,8 @@ namespace Volo.Abp.VirtualFileSystem
_dynamicFileProvider.AddOrUpdate(
new InMemoryFileInfo(
"Hello World UPDATED".GetBytes(),
"/my-files/test.txt",
"Hello World UPDATED".GetBytes(),
"test.txt"
)
);
@ -74,8 +73,8 @@ namespace Volo.Abp.VirtualFileSystem
_dynamicFileProvider.AddOrUpdate(
new InMemoryFileInfo(
"Hello World UPDATED 2".GetBytes(),
"/my-files/test.txt",
"Hello World UPDATED 2".GetBytes(),
"test.txt"
)
);
@ -88,7 +87,7 @@ namespace Volo.Abp.VirtualFileSystem
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
}
}
}

Loading…
Cancel
Save