mirror of https://github.com/abpframework/abp
Introduce Volo.Abp.Autofac.WebAssembly package, move ABP application creation code to the framework.
parent
7d1a705df0
commit
b510e00ffc
@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using JetBrains.Annotations;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.AspNetCore.Components.WebAssembly;
|
||||
using Volo.Abp.Modularity;
|
||||
|
||||
namespace Microsoft.AspNetCore.Components.WebAssembly.Hosting
|
||||
{
|
||||
public static class AbpWebAssemblyHostBuilderExtensions
|
||||
{
|
||||
public static IAbpApplicationWithExternalServiceProvider AddApplication<TStartupModule>(
|
||||
[NotNull] this WebAssemblyHostBuilder builder,
|
||||
Action<AbpWebAssemblyApplicationCreationOptions> options)
|
||||
where TStartupModule : IAbpModule
|
||||
{
|
||||
Check.NotNull(builder, nameof(builder));
|
||||
|
||||
builder.Services.AddSingleton<IConfiguration>(builder.Configuration);
|
||||
builder.Services.AddSingleton(builder);
|
||||
|
||||
var application = builder.Services.AddApplication<TStartupModule>(opts =>
|
||||
{
|
||||
options?.Invoke(new AbpWebAssemblyApplicationCreationOptions(builder, opts));
|
||||
});
|
||||
|
||||
return application;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
|
||||
|
||||
namespace Volo.Abp.AspNetCore.Components.WebAssembly
|
||||
{
|
||||
public class AbpWebAssemblyApplicationCreationOptions
|
||||
{
|
||||
public WebAssemblyHostBuilder HostBuilder { get; }
|
||||
|
||||
public AbpApplicationCreationOptions ApplicationCreationOptions { get; }
|
||||
|
||||
public AbpWebAssemblyApplicationCreationOptions(
|
||||
WebAssemblyHostBuilder hostBuilder,
|
||||
AbpApplicationCreationOptions applicationCreationOptions)
|
||||
{
|
||||
HostBuilder = hostBuilder;
|
||||
ApplicationCreationOptions = applicationCreationOptions;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="..\..\..\configureawait.props" />
|
||||
<Import Project="..\..\..\common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<RootNamespace />
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Volo.Abp.AspNetCore.Components.WebAssembly\Volo.Abp.AspNetCore.Components.WebAssembly.csproj" />
|
||||
<ProjectReference Include="..\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Loading…
Reference in new issue