一、AbpEfConsoleApp
using System; using Abp; using Abp.Dependency; using Castle.Facilities.Logging; namespace AbpEfConsoleApp { public class Program { static void Main(string[] args) { //引导ABP系统 using (var bootstrapper = AbpBootstrapper.Create<MyConsoleAppModule>()) { bootstrapper.IocManager .IocContainer .AddFacility<LoggingFacility>(f => f.UseLog4Net().WithConfig("log4net.config")); bootstrapper.Initialize(); //从DI获取测试对象并运行它 using (var tester = bootstrapper.IocManager.ResolveAsDisposable<Tester>()) { tester.Object.Run(); } //部署测试和所有它的依赖 Console.WriteLine("Press enter to exit..."); Console.ReadLine(); } } } }
using System.Reflection; using Abp.EntityFramework; using Abp.Modules; namespace AbpEfConsoleApp { //定义模块取决于AbpEntityFrameworkModule [DependsOn(typeof(AbpEntityFrameworkModule))] public class MyConsoleAppModule : AbpModule { public override void Initialize() { IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly()); } } }
二、AbpSwaggerDemo
using System.Reflection; using Abp.Application.Services; using Abp.Modules; using Abp.WebApi; using Abp.WebApi.Controllers.Dynamic.Builders; using OtherApp.Application; namespace AbpSwagger.Application.WebApi.WebApi { [DependsOn( typeof(AbpWebApiModule), typeof(AbpSwaggerAppModule), typeof(OtherAppModule))] public class SwaggerWebApiModule : AbpModule { public override void Initialize() { IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly()); DynamicApiControllerBuilder .ForAll<IApplicationService>(typeof(AbpSwaggerAppModule).Assembly, "app") .WithConventionalVerbs() .Build(); DynamicApiControllerBuilder .ForAll<IApplicationService>(typeof(OtherAppModule).Assembly, "app") .Build(); } } }
原文:http://www.cnblogs.com/zd1994/p/7717260.html