/*** * _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().AsSelf().SingleInstance(); #region 注册通知服务 Assembly[] assemblies = AppTypeFinder.Assemblies.ToArray(); builder.Register(ctx => new MediatorManager( new AutofacNotificationServiceProvider(ctx.Resolve()))) .As().AsSelf().InstancePerLifetimeScope(); builder.RegisterAssemblyTypes(assemblies) .AsClosedTypesOf(typeof(INotificationHandler<>)) .AsImplementedInterfaces() .AsSelf() .InstancePerLifetimeScope(); #endregion } }