|
|
@ -1,7 +1,11 @@ |
|
|
using System.Collections.Generic; |
|
|
using System; |
|
|
|
|
|
using System.Collections.Generic; |
|
|
using System.Linq; |
|
|
using System.Linq; |
|
|
using System.Reflection; |
|
|
using System.Reflection; |
|
|
using Microsoft.AspNetCore.Mvc.ApplicationParts; |
|
|
using Microsoft.AspNetCore.Mvc.ApplicationParts; |
|
|
|
|
|
using Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation; |
|
|
|
|
|
using Volo.Abp.AspNetCore.VirtualFileSystem; |
|
|
|
|
|
using Volo.Abp.DependencyInjection; |
|
|
|
|
|
|
|
|
namespace Microsoft.Extensions.DependencyInjection |
|
|
namespace Microsoft.Extensions.DependencyInjection |
|
|
{ |
|
|
{ |
|
|
@ -11,12 +15,12 @@ namespace Microsoft.Extensions.DependencyInjection |
|
|
{ |
|
|
{ |
|
|
mvcBuilder.PartManager.ApplicationParts.AddIfNotContains(assembly); |
|
|
mvcBuilder.PartManager.ApplicationParts.AddIfNotContains(assembly); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static void AddApplicationPartIfNotExists(this IMvcCoreBuilder mvcCoreBuilder, Assembly assembly) |
|
|
public static void AddApplicationPartIfNotExists(this IMvcCoreBuilder mvcCoreBuilder, Assembly assembly) |
|
|
{ |
|
|
{ |
|
|
mvcCoreBuilder.PartManager.ApplicationParts.AddIfNotContains(assembly); |
|
|
mvcCoreBuilder.PartManager.ApplicationParts.AddIfNotContains(assembly); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static void AddIfNotContains(this IList<ApplicationPart> applicationParts, Assembly assembly) |
|
|
public static void AddIfNotContains(this IList<ApplicationPart> applicationParts, Assembly assembly) |
|
|
{ |
|
|
{ |
|
|
if (applicationParts.Any( |
|
|
if (applicationParts.Any( |
|
|
@ -27,5 +31,18 @@ namespace Microsoft.Extensions.DependencyInjection |
|
|
|
|
|
|
|
|
applicationParts.Add(new AssemblyPart(assembly)); |
|
|
applicationParts.Add(new AssemblyPart(assembly)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void AddAbpRazorRuntimeCompilation(this IMvcCoreBuilder mvcCoreBuilder) |
|
|
|
|
|
{ |
|
|
|
|
|
mvcCoreBuilder.AddRazorRuntimeCompilation(); |
|
|
|
|
|
mvcCoreBuilder.Services.Configure<MvcRazorRuntimeCompilationOptions>(options => |
|
|
|
|
|
{ |
|
|
|
|
|
options.FileProviders.Add( |
|
|
|
|
|
new RazorViewEngineVirtualFileProvider( |
|
|
|
|
|
mvcCoreBuilder.Services.GetSingletonInstance<IObjectAccessor<IServiceProvider>>() |
|
|
|
|
|
) |
|
|
|
|
|
); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|