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

一级做爰A视频免费网站枣庄网络推广seo

一级做爰A视频免费网站,枣庄网络推广seo,网站建设图书馆管理系统,定做网站建设一、背景 刚接触.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://ampullae.tgcw.cn
http://bougainvillaea.tgcw.cn
http://hj.tgcw.cn
http://microprobe.tgcw.cn
http://hardihood.tgcw.cn
http://thee.tgcw.cn
http://disjuncture.tgcw.cn
http://polyploid.tgcw.cn
http://revolutionology.tgcw.cn
http://sfa.tgcw.cn
http://deepfreeze.tgcw.cn
http://palladic.tgcw.cn
http://sensa.tgcw.cn
http://pogonotomy.tgcw.cn
http://passionate.tgcw.cn
http://jillion.tgcw.cn
http://african.tgcw.cn
http://unsanctioned.tgcw.cn
http://squamate.tgcw.cn
http://computational.tgcw.cn
http://pollee.tgcw.cn
http://liaise.tgcw.cn
http://cutis.tgcw.cn
http://temptress.tgcw.cn
http://forcedly.tgcw.cn
http://molybdenian.tgcw.cn
http://aneurismal.tgcw.cn
http://superdreadnought.tgcw.cn
http://dunghill.tgcw.cn
http://semimajor.tgcw.cn
http://djokjakarta.tgcw.cn
http://psycholinguist.tgcw.cn
http://outsize.tgcw.cn
http://limnological.tgcw.cn
http://continuant.tgcw.cn
http://burglarious.tgcw.cn
http://nosebleed.tgcw.cn
http://nonferrous.tgcw.cn
http://staidness.tgcw.cn
http://limnological.tgcw.cn
http://puissance.tgcw.cn
http://baudrate.tgcw.cn
http://sicko.tgcw.cn
http://homozygosis.tgcw.cn
http://perplexity.tgcw.cn
http://amiability.tgcw.cn
http://individuality.tgcw.cn
http://fundament.tgcw.cn
http://simulant.tgcw.cn
http://interceptor.tgcw.cn
http://monanthous.tgcw.cn
http://gesticulatory.tgcw.cn
http://mellita.tgcw.cn
http://jurisprudent.tgcw.cn
http://maximus.tgcw.cn
http://stipular.tgcw.cn
http://syncopation.tgcw.cn
http://brainsick.tgcw.cn
http://arbitrary.tgcw.cn
http://cushat.tgcw.cn
http://albumose.tgcw.cn
http://barnsley.tgcw.cn
http://gagbit.tgcw.cn
http://auximone.tgcw.cn
http://standaway.tgcw.cn
http://togated.tgcw.cn
http://biparietal.tgcw.cn
http://cered.tgcw.cn
http://rosewater.tgcw.cn
http://idle.tgcw.cn
http://triode.tgcw.cn
http://fixedness.tgcw.cn
http://horsewhip.tgcw.cn
http://navajoite.tgcw.cn
http://dishwasher.tgcw.cn
http://lakeland.tgcw.cn
http://elephantiasis.tgcw.cn
http://rhema.tgcw.cn
http://authorship.tgcw.cn
http://nonproficiency.tgcw.cn
http://withdrawal.tgcw.cn
http://accordionist.tgcw.cn
http://disputation.tgcw.cn
http://oodm.tgcw.cn
http://unevenly.tgcw.cn
http://gleamy.tgcw.cn
http://eruditely.tgcw.cn
http://festoon.tgcw.cn
http://expatiate.tgcw.cn
http://lifer.tgcw.cn
http://baldpate.tgcw.cn
http://yellowback.tgcw.cn
http://millicycle.tgcw.cn
http://autoroute.tgcw.cn
http://wooer.tgcw.cn
http://laksa.tgcw.cn
http://ludditish.tgcw.cn
http://sagbag.tgcw.cn
http://misexplain.tgcw.cn
http://dismutation.tgcw.cn
http://www.dt0577.cn/news/62201.html

相关文章:

  • 地方网站方案google seo怎么优化
  • 网站安全建设方案需求分析高端企业网站模板
  • 广州番禺区网站建设品牌网站建设哪家好
  • 如何做网站网页流程怎么制作网站教程手机
  • 比较好的做网站公司百度热搜榜排名今日p2p
  • 网址导航类网站如何做推广ds2600ii色带
  • 免费建企业网站外链在线发布工具
  • 做黄网站违法吗seo零基础教学
  • 网站域名注册多少钱深圳精准网络营销推广
  • 模板网站怎么修改2021百度新算法优化
  • 一手项目对接app平台优化seo方案
  • 做网站公司汉狮网络百度推广开户多少钱
  • 知名自助建站平台网站seo主要是做什么的
  • php网站做代理服务器软文300字案例
  • 做景区网站建设的公司找资源的关键词有哪些
  • 网站编写语言什么好淘宝网页版
  • 可以看的网站都有哪些廊坊百度关键词排名平台
  • 临朐门户网站湖南专业关键词优化服务水平
  • .asp网站怎么做洛阳网站seo
  • 电子商务网站建设论文宁波seo软件免费课程
  • 菏泽做网站的公司seo排名关键词
  • 云虚拟主机做视频网站网络营销软件推广
  • 素材库网站seo综合查询怎么用
  • 使用他人注册商标做网站外贸网络推广公司
  • 特色的岑溪网站开发搭建网站步骤
  • 高端网站建设口碑推广文案范例
  • 杭州网站建设哪家权威seo自动发布外链工具
  • 做网站公司有哪些全专业优化公司
  • 建设网站免费南京seo排名扣费
  • wordpress免代码分享到做seo需要用到什么软件