#region << 版 本 注 释 >> /*---------------------------------------------------------------- * 命å空间:WIDESEAWCS_QuartzJob * 创建者:胡童庆 * 创建时间:2024/8/2 16:13:36 * 版本:V1.0.0 * æè¿°ï¼šè°ƒåº¦æœåŠ¡ä»“å‚¨ä¸šåŠ¡å±‚æ³¨å…¥ * * ---------------------------------------------------------------- * 修改人: * 修改时间: * 版本:V1.0.1 * 修改说明: * *----------------------------------------------------------------*/ #endregion << 版 本 注 释 >> using Autofac; using Autofac.Extras.DynamicProxy; using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; using WIDESEAWCS_Core; using WIDESEAWCS_Core.AOP; using WIDESEAWCS_Core.BaseRepository; using WIDESEAWCS_Core.BaseServices; using WIDESEAWCS_QuartzJob.Repository; using WIDESEAWCS_QuartzJob.Service; namespace WIDESEAWCS_QuartzJob.QuartzExtensions { public class QuartzJobAutofacModuleRegister : Autofac.Module { protected override void Load(ContainerBuilder builder) { var basePath = AppContext.BaseDirectory; #region 带有接å£å±‚çš„æœåŠ¡æ³¨å…¥ var dllFile = Path.Combine(basePath, "WIDESEAWCS_QuartzJob.dll"); if (!File.Exists(dllFile)) { var msg = "WIDESEAWCS_QuartzJob.dll ä¸¢å¤±ï¼Œå› ä¸ºé¡¹ç›®è§£è€¦äº†ï¼Œæ‰€ä»¥éœ€è¦å…ˆF6编译,å†F5è¿è¡Œï¼Œè¯·æ£€æŸ¥ bin 文件夹,并拷è´ã€‚"; //log.Error(msg); throw new Exception(msg); } Type baseType = typeof(IDependency); //builder.RegisterGeneric(typeof(RepositoryBase<>)).As(typeof(IRepository<>)).InstancePerDependency();//注册仓储 //builder.RegisterGeneric(typeof(ServiceBase<,>)).As(typeof(IService<>)).InstancePerDependency();//注册æœåŠ¡ // èŽ·å– Service.dll 程åºé›†æœåŠ¡ï¼Œå¹¶æ³¨å†Œ Assembly assemblysServices = Assembly.LoadFrom(dllFile); builder.RegisterAssemblyTypes(assemblysServices).Where(type => (baseType.IsAssignableFrom(type)) && !type.IsAbstract) .AsSelf().AsImplementedInterfaces() .InstancePerLifetimeScope(); //引用Autofac.Extras.DynamicProxy; #endregion } } }