AbpZero的精髓就在于多租户模块化加载,如果不做到这两种的话,就没必要使用这个框架。
1、首先,我们得新建一个类库,用于存放我们写的业务代码。
在类库下分别建立三个类文件:TestAppService ,ITestAppService ,TestModule,一下是对应代码:
TestModule:
1 using Abp.Modules; 2 using Abp.Reflection.Extensions; 3 using System; 4 using System.Collections.Generic; 5 using System.Text; 7 8 namespace Test 9 { 10 public class TestModule : AbpModule 11 { 12 13 public override void PreInitialize() 14 { 15 16 } 17 18 public override void Initialize() 19 { 20 IocManager.RegisterAssemblyByConvention(typeof(TestModule).GetAssembly()); 21 } 22 23 public override void PostInitialize() 24 { 25 IocManager.Register<ITestAppService, TestAppService>(); 26 var test= IocManager.Resolve<ITestAppService>(); 27 test.Sender = IocManager.Resolve<ITestAppService>(typeof(TestAppService)); 28 } 29 } 30 }
ITestAppService :
1 using System.Threading.Tasks; 4 namespace Test 5 { 6 public interface ITestAppService:IApplicationService 7 { 11 Task<string> GetTest(); 12 } 13 }
TestAppService :
using Abp.Application.Services.Dto; using Abp.AutoMapper; using Abp.Domain.Repositories; using Abp.UI; using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Data; namespace Tensee.Banch.Attendance { public class AttendanceSchemeAppService : BanchAppServiceBase, IAttendanceSchemeAppService { pubilc async Task<string> GetTest(){ return "这是模块化懒加载"; } } }
2、生成对应的Test.dll,拷贝这个dll到
运行swagger就可以了。