Files
Store.Management/Source/Core/MAX.Core/Startup.cs
T
2026-10-27 14:35:03 +08:00

65 lines
1.7 KiB
C#

/***
* _ooOoo_
* o8888888o
* 88" . "88
* (| -_- |)
* O\ = /O
* ____/`---'\____
* . ' \\| |// `.
* / \\||| : |||// \
* / _||||| -:- |||||- \
* | | \\\ - /// | |
* | \_| ''\---/'' | |
* \ .-\__ `-` ___/-. /
* ___`. .' /--.--\ `. . __
* ."" '< `.___\_<|>_/___.' >'"".
* | | : `- \`.;`\ _ /`;.`/ - ` : | |
* \ \ `-. \_ __\ /__ _/ .-` / /
* ======`-.____`-.___\_____/___.-`____.-'======
* `=---='
*
* .............................................
* 佛祖保佑 永无BUG
* 快加工资 不改需求
*/
using Autofac;
using MAX.Core.DependencyInjection;
using MAX.Core.Infrastructure;
using MAX.Core.Reflections;
using MAX.Notification;
using System.Reflection;
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 注册通知服务
Assembly[] assemblies = AppTypeFinder.Assemblies.ToArray();
builder.Register(ctx => new MediatorManager(
new AutofacNotificationServiceProvider(ctx.Resolve<ILifetimeScope>())))
.As<IPublisher>().AsSelf().InstancePerLifetimeScope();
builder.RegisterAssemblyTypes(assemblies)
.AsClosedTypesOf(typeof(INotificationHandler<>))
.AsImplementedInterfaces()
.AsSelf()
.InstancePerLifetimeScope();
#endregion
}
}