abp-ConsoleProject(abp-ConsoleProject)

1.引入ABP

2.添加自定义module,继承AbpModule

public class MyAbpModule : AbpModule
    {
        public override void Initialize()
        {
            IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
        }
    }
}

3,添加自己的service,继承ITransientDependency

 //[Dependency(ServiceLifetime.Transient)]
    public class Service : ITransientDependency
    {
        public void Run()
        {
            Console.WriteLine("你好");
        }
    }

4.具体实现

 static void Main(string[] args)
        {
            using (var bootstrapper = AbpBootstrapper.Create<MyAbpModule>())
            {
                bootstrapper.Initialize();

                var service = IocManager.Instance.Resolve<Service>();
                service.Run();
                Console.ReadKey();
            }
        }

相关分析,

01 AbpBootstrapper:

————————

1. Introduction of ABP

2. Add a custom module and inherit abpmodule

public class MyAbpModule : AbpModule
    {
        public override void Initialize()
        {
            IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
        }
    }
}

3,添加自己的service,继承ITransientDependency

 //[Dependency(ServiceLifetime.Transient)]
    public class Service : ITransientDependency
    {
        public void Run()
        {
            Console.WriteLine("你好");
        }
    }

4. Concrete realization

 static void Main(string[] args)
        {
            using (var bootstrapper = AbpBootstrapper.Create<MyAbpModule>())
            {
                bootstrapper.Initialize();

                var service = IocManager.Instance.Resolve<Service>();
                service.Run();
                Console.ReadKey();
            }
        }

Correlation analysis,

01 AbpBootstrapper: