反射和IOC

1.反射的作用

  • 它允许在运行时查看特性(attribute)信息。
  • 它允许审查集合中的各种类型,以及实例化这些类型

2.

        Assembly assembly = Assembly.LoadFrom(rootPath+ "\\bin\\Debug\\netcoreapp3.1\\WebApiDemo.dll"); //加载DLL
        Type typeObj = assembly.GetType("WebApiDemo.Model.Car");//获得类型,FullName
        object o = Activator.CreateInstance(typeObj);//创建实例

 

posted @ 2021-07-21 18:02  留下成长的足迹  阅读(52)  评论(0编辑  收藏  举报