78 lines
2.0 KiB
C#
78 lines
2.0 KiB
C#
/***
|
|
* _ooOoo_
|
|
* o8888888o
|
|
* 88" . "88
|
|
* (| -_- |)
|
|
* O\ = /O
|
|
* ____/`---'\____
|
|
* . ' \\| |// `.
|
|
* / \\||| : |||// \
|
|
* / _||||| -:- |||||- \
|
|
* | | \\\ - /// | |
|
|
* | \_| ''\---/'' | |
|
|
* \ .-\__ `-` ___/-. /
|
|
* ___`. .' /--.--\ `. . __
|
|
* ."" '< `.___\_<|>_/___.' >'"".
|
|
* | | : `- \`.;`\ _ /`;.`/ - ` : | |
|
|
* \ \ `-. \_ __\ /__ _/ .-` / /
|
|
* ======`-.____`-.___\_____/___.-`____.-'======
|
|
* `=---='
|
|
*
|
|
* .............................................
|
|
* 佛祖保佑 永无BUG
|
|
* 快加工资 不改需求
|
|
*/
|
|
|
|
|
|
using Autofac;
|
|
using MAX.Core.DependencyInjection;
|
|
using MAX.Core.Infrastructure;
|
|
using MAX.Core.Reflections;
|
|
using MediatR;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Reflection;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace MAX.Core;
|
|
|
|
public class Startup : IStartup
|
|
{
|
|
public int Priority => int.MaxValue;
|
|
|
|
public void Initialize()
|
|
{
|
|
|
|
}
|
|
|
|
public void Register(ContainerBuilder builder)
|
|
{
|
|
builder.RegisterInstance(LazyServiceProvider.Instance).As<ILazyServiceProvider>().AsSelf().SingleInstance();
|
|
|
|
#region 注册MediatR
|
|
Assembly[] assemblies = AppTypeFinder.Assemblies.ToArray();
|
|
|
|
builder.RegisterType<MediatorManager>().As<IMediator>().AsSelf().SingleInstance();
|
|
|
|
builder.RegisterAssemblyTypes(assemblies)
|
|
.AsClosedTypesOf(typeof(INotificationHandler<>))
|
|
.AsImplementedInterfaces()
|
|
.AsSelf()
|
|
.InstancePerLifetimeScope();
|
|
|
|
builder.RegisterAssemblyTypes(assemblies)
|
|
.AsClosedTypesOf(typeof(IRequestHandler<>))
|
|
.AsImplementedInterfaces()
|
|
.AsSelf()
|
|
.InstancePerLifetimeScope();
|
|
|
|
builder.Register<ServiceFactory>(ctx =>
|
|
{
|
|
var c = ctx.Resolve<IComponentContext>();
|
|
return t => c.Resolve(t);
|
|
}).SingleInstance();
|
|
|
|
#endregion
|
|
}
|
|
} |