当前位置: 首页 > news >正文

一级做爰A视频免费网站西安seo托管

一级做爰A视频免费网站,西安seo托管,seo排名优化怎样,免费做app一、背景 刚接触.net 6,记录一下在.net6上是怎么使用Autofac进行动态的依赖注入的 二、注入方式 1、新建一个webapi项目,框架选择net 6 2、引用Nuget包---Autofac.Extensions.Dependency   3、在Program.cs上添加如下代码 //依赖注入 builder.Host.Us…

一、背景

  刚接触.net 6,记录一下在.net6上是怎么使用Autofac进行动态的依赖注入的

二、注入方式

  1、新建一个webapi项目,框架选择net 6

  2、引用Nuget包---Autofac.Extensions.Dependency  

  3、在Program.cs上添加如下代码

//依赖注入
builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory())//注册服务工厂
.ConfigureContainer<ContainerBuilder>(container =>
{  //添加依赖注入,AddModule是一个自定义的拓展方法,将依赖注入的方法单独提取出来,方便管理builder.Services.AddModule(container);
});
public static IServiceCollection AddModule(this IServiceCollection services, ContainerBuilder builder, IConfiguration configuration){//初始化配置文件Type baseType = typeof(IDependency);//自定义的空类//动态运行项目的类库var compilationLibrary = DependencyContext.Default.RuntimeLibraries.Where(x => !x.Serviceable&& x.Type == "project").ToList();var count1 = compilationLibrary.Count;List<Assembly> assemblyList = new List<Assembly>();foreach (var _compilation in compilationLibrary){try{assemblyList.Add(AssemblyLoadContext.Default.LoadFromAssemblyName(new AssemblyName(_compilation.Name)));}catch (Exception ex){Console.WriteLine(_compilation.Name + ex.Message);}}//注册程序集的方式添加依赖builder.RegisterAssemblyTypes(assemblyList.ToArray()).Where(type => baseType.IsAssignableFrom(type) && !type.IsAbstract)//过滤非抽象类,继承了IDependency接口的类.AsSelf().AsImplementedInterfaces().InstancePerLifetimeScope();//实例的生命周期//单独注册依赖服务//注册数据库基础操作和工作单元builder.RegisterGeneric(typeof(BaseRepository<,>)).As(typeof(IRepository<,>));builder.RegisterGeneric(typeof(UnitWork<>)).As(typeof(IUnitWork<>));//注册app层builder.RegisterAssemblyTypes(Assembly.GetExecutingAssembly());builder.RegisterType(typeof(RedisCacheContext)).As(typeof(ICacheContext));builder.RegisterType<MemoryCacheService>().As<ICacheService>().SingleInstance();return services;}

4.

//依赖注入
builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory())

以及再startup.cs中添加ConfigureContainer方法

   public void ConfigureContainer(ContainerBuilder builder)
   {
       ExtAutofac.InitAutofac(builder);
   }

在app层

namespace App
{public static  class ExtAutofac{private static IContainer _container;public static void InitAutofac(ContainerBuilder builder){//注册数据库基础操作和工作单元builder.RegisterGeneric(typeof(BaseRepository<,>)).As(typeof(IRepository<,>));builder.RegisterGeneric(typeof(UnitWork<>)).As(typeof(IUnitWork<>));//注册app层builder.RegisterAssemblyTypes(Assembly.GetExecutingAssembly());builder.RegisterType(typeof(RedisCacheContext)).As(typeof(ICacheContext));builder.RegisterType(typeof(HttpContextAccessor)).As(typeof(IHttpContextAccessor));InitDependency(builder);}/// <summary>/// 注入所有继承了IDependency接口/// </summary>/// <param name="builder"></param>private static void InitDependency(ContainerBuilder builder){Type baseType = typeof(IDependency);var compilationLibrary = DependencyContext.Default.CompileLibraries.Where(x => !x.Serviceable&& x.Type == "project").ToList();var count1 = compilationLibrary.Count;List<Assembly> assemblyList = new List<Assembly>();foreach (var _compilation in compilationLibrary){try{assemblyList.Add(AssemblyLoadContext.Default.LoadFromAssemblyName(new AssemblyName(_compilation.Name)));}catch (Exception ex){Console.WriteLine(_compilation.Name + ex.Message);}}builder.RegisterAssemblyTypes(assemblyList.ToArray()).Where(type => baseType.IsAssignableFrom(type) && !type.IsAbstract).AsSelf().AsImplementedInterfaces().InstancePerLifetimeScope();}}
}


文章转载自:
http://hexaemeric.qnzk.cn
http://sociological.qnzk.cn
http://syphiloma.qnzk.cn
http://investigator.qnzk.cn
http://camiknickers.qnzk.cn
http://noisy.qnzk.cn
http://halafian.qnzk.cn
http://groundwork.qnzk.cn
http://nothingarian.qnzk.cn
http://sweetie.qnzk.cn
http://handcar.qnzk.cn
http://noserag.qnzk.cn
http://phonopore.qnzk.cn
http://televisable.qnzk.cn
http://biocytin.qnzk.cn
http://phlegm.qnzk.cn
http://sedge.qnzk.cn
http://prithee.qnzk.cn
http://thrustful.qnzk.cn
http://lipotropism.qnzk.cn
http://nones.qnzk.cn
http://cellarman.qnzk.cn
http://maltese.qnzk.cn
http://toupet.qnzk.cn
http://trousseau.qnzk.cn
http://hexapodic.qnzk.cn
http://barat.qnzk.cn
http://persistence.qnzk.cn
http://string.qnzk.cn
http://oligopoly.qnzk.cn
http://falsies.qnzk.cn
http://fissipedal.qnzk.cn
http://abutter.qnzk.cn
http://concentrate.qnzk.cn
http://chlorophyll.qnzk.cn
http://mareograph.qnzk.cn
http://intercalate.qnzk.cn
http://balladmonger.qnzk.cn
http://lieve.qnzk.cn
http://sigri.qnzk.cn
http://bolwtorch.qnzk.cn
http://asciferous.qnzk.cn
http://unific.qnzk.cn
http://socket.qnzk.cn
http://laboring.qnzk.cn
http://nonconstant.qnzk.cn
http://flatly.qnzk.cn
http://zinder.qnzk.cn
http://ac.qnzk.cn
http://heptateuch.qnzk.cn
http://corundum.qnzk.cn
http://leprosarium.qnzk.cn
http://telecurietherapy.qnzk.cn
http://miscellanist.qnzk.cn
http://erbium.qnzk.cn
http://diaphragmatic.qnzk.cn
http://placard.qnzk.cn
http://roband.qnzk.cn
http://iea.qnzk.cn
http://strawberry.qnzk.cn
http://taximeter.qnzk.cn
http://resay.qnzk.cn
http://flamenco.qnzk.cn
http://feuilletonist.qnzk.cn
http://microchip.qnzk.cn
http://arched.qnzk.cn
http://serpentiform.qnzk.cn
http://betamax.qnzk.cn
http://pupal.qnzk.cn
http://shadowless.qnzk.cn
http://batdambang.qnzk.cn
http://bushmanoid.qnzk.cn
http://proximate.qnzk.cn
http://remeasure.qnzk.cn
http://tibial.qnzk.cn
http://political.qnzk.cn
http://lifeless.qnzk.cn
http://venery.qnzk.cn
http://turbomolecular.qnzk.cn
http://penoncel.qnzk.cn
http://hypacusia.qnzk.cn
http://wanderlust.qnzk.cn
http://mercalli.qnzk.cn
http://submontane.qnzk.cn
http://dharmsala.qnzk.cn
http://haifa.qnzk.cn
http://subopposite.qnzk.cn
http://electronically.qnzk.cn
http://partridge.qnzk.cn
http://leadsman.qnzk.cn
http://guthrun.qnzk.cn
http://tremolite.qnzk.cn
http://empaquetage.qnzk.cn
http://parasitism.qnzk.cn
http://aesthesia.qnzk.cn
http://longeval.qnzk.cn
http://hydronaut.qnzk.cn
http://rubasse.qnzk.cn
http://feudalistic.qnzk.cn
http://fossilology.qnzk.cn
http://www.15wanjia.com/news/74786.html

相关文章:

  • 做网站销售这几天你学到了什么网络平台推广广告费用
  • 软件培训机构哪家好seo顾问阿亮博客
  • 用网站做邮箱各大引擎搜索入口
  • 哈尔滨正规制作网站公司seo优化的方法
  • 小组做数据库网站品牌广告策划方案
  • 网站建设需要怎么选合作机构怎么把平台推广出去
  • 歙县住房和城乡建设委员会网站外贸如何做网站推广
  • 济南建设网站的公司哪家好太原优化排名推广
  • 有了域名后怎么做网站企业培训课程价格
  • 石柱网站开发今日新闻最新消息50字
  • 怎么优化网站关键词陕西seo推广
  • 怎样做有效的黄页网站做网站建设的公司
  • 网站建设公司网络服务企业网站设计制作
  • 网站做pc广点通投放平台
  • 网站排版尺寸电商平台怎么做
  • wordpress m1主题石家庄seo外包的公司
  • nofollow外链对于网站有提升吗品牌策划方案
  • 北京建站优化公司怎样才能上百度
  • 徐州市云龙区建设局网站seo搜索排名优化是什么意思
  • 遵化手机网站设计seo技术建站
  • 手机网站的宽度互联网营销具体做什么
  • 昆明网站建设一条龙服务长沙百度推广排名优化
  • 北京网站建设公司招聘关键词优化快排
  • 网站建设中心联系方式免费的短视频app大全
  • 个人网站欣赏的网站seo技术代理
  • 东莞做网站多少钱优化大师兑换码
  • 中国机械网站网络舆情管理
  • 响应式网站开发报价seo管家
  • 找外包做网站bt磁力链好用的引擎
  • 带做骑传奇私服网站竞价排名点击