码迷,mamicode.com
首页 > 其他好文 > 详细

ABP-Samples学习笔记

时间:2017-10-23 18:42:46      阅读:396      评论:0      收藏:0      [点我收藏+]

标签:sem   mod   ble   alt   pen   ini   ati   ram   obj   

一、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();
        }
    }
}

 

ABP-Samples学习笔记

标签:sem   mod   ble   alt   pen   ini   ati   ram   obj   

原文地址:http://www.cnblogs.com/zd1994/p/7717260.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!