C# 读Autofac源码笔记(2)
刚看了下Autofac属性注入的源码
首先看看WithProperty方法
![](https://upload-images.jianshu.io/upload_images/2832200-209332cf8eb64e59.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
image.png
Autofac将我们的属性值,存在了一个list集合中
![](https://upload-images.jianshu.io/upload_images/2832200-343099d821753315.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
image.png
然后将这个集合传递到了ReflectionActivator对象中
![](https://upload-images.jianshu.io/upload_images/2832200-fcae1079dac2533b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/413)
image.png
![](https://upload-images.jianshu.io/upload_images/2832200-ea77da144a33e7b4.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
image.png
然后在我们Resolve生成对象实例后,Autofac调用属性注入代码
![](https://upload-images.jianshu.io/upload_images/2832200-892b776e87a15d31.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
image.png
![](https://upload-images.jianshu.io/upload_images/2832200-2626833fde0606d8.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
image.png
最后返回整个实例。