转载地址:http://www.cnblogs.com/JustRun1983/archive/2013/03/28/2981645.html 有修改
Autofac通过Controller默认构造函数实现依赖注入原理:
我们知道,MVC处理一个请求时,首先从请求的URL中解析出对应Route然后根据Route去找到对应的Controller和Action,然后执行Action方法返回请求结果。Controller的实例化是由一个叫DefaultControllerFactor的类去完成的,而在DefaultControllerFactor类中,具体的实例化工作又是由一个实现了IDependencyResolver接口的类去完成的,而这个接口,就是我们实现Controller注入的切入点,我们可以创建一个实现了IDependencyResolver接口的类,然后把这个类在Application_Start事件中设置进去,然后对于每一个Controller的实例化,我们都可以进行干涉,我们可以拿到默认构造函数的所有参数,并根据IOC容器中注册的类型对参数进行实例化,当然,在这里我们要用到的是AutoFac这个轻量注入工具,上面所说的具体事情都由这个类完成了,我们要做的就是在Application_Start事件中把它注册进去。
本篇文章,讲解如何使用Auotfac, Asp.net MVC和EF Code First,搭建一个松散的架构。 例子代码主要完成的功能是:
列出数据库中Student表中的所有学生信息。
阅读目录:
一、 使用Entity Framework Code First, 写代码创建Student表
二、使用Migrations, 生成数据库和初始化数据
三、创建Controller方法和View
四、正式项目开发中的困境
五、解耦合,脱离数据层
六、实例化,可恶的实例化
七、使用Autofac依赖注入
八、总结
一、使用Entity Framework Code First, 写代码创建Student表
public class SchoolContext : DbContext
{
public SchoolContext()
: base("DefaultConnection")
{
} public DbSet<Student> Students { get; set; }
} [Table("Student")]
public class Student
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
public int Age { get; set; }
}
二、使用Migrations, 生成数据库和初始化数据
打开"package manager console"
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAmwAAAGrCAIAAADy8lzjAAAgAElEQVR4nO29748cx53YzX/BwL054NAvnnd5E8DB3ZvnkH03TU0CBHge63kpAgGCnNgZCuLpAuTRSSEQG7Lk9hyxvmUQW+eV7Fi64wxuRBOKKIXxyjaoeMbe2dUxPJPUWqKo5XJnxJX3jlIS2XcH50X/qqqu6h8zPdM93Z/CB8Swt7uquqe7PlPf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ds335tfomIUd+jafmMt2SVo4rUb43lGo4yGTmQ0/0iRn9QPE3ppYYrGXMUeZM9RijP5SSdRrZNS8k8rK34WmoJMB2YsFyArSJRUnZQQzt3ZvW5Z1s7ude1tbOqGeiid0RSJ7t89ePWVVx977LGzZ/9wbomKihJENY9EIxkneyLs+CoSTZBNQFESNY2JFiBR+SyQKJQHEiVVJykS3dm9HvLmm1cty3rzzavixvA2NnVDPZTOaIpEr1175+pbV5955tnH/+DxUKIzfj1UnQ0USiV/OLffDf4bhi51rX9YoiYMe2QcWNVMaxLDnkoQNbtE/W5xbHZucv5ZylLOYrZwbpZy004QGg8SJVUnKRJVO3GxFN7Gpm7oiROazmh6ONfrhl679o63xfu6ywxPV89RJ6pEEd1+OJNFmEOk3egTn7yjbf2D+TXRl2rk1l+MhardWYFot4xiCyY0xb8OK5YYfqRIyj+9rNhZSNfH06RQH+2BGctFopACEiVVJ83/FRelGxpKVOyMpodzFWaWKADUHiRKqk6avyeqjIaGEhU7o0aJJiQkCgBakCipOkmR6H95462Q73z3FcuyvvPdV8SN4W1sGg0VCTujeommptKfVQCoIEiUVJ005+xcpRuq9ETDziiLcgNAYSBRUnWSSaJbb//4pZe+a1nW4LXvD177fvw29iT66aef/sNb/0TbDY06o599hkQBoDCQKKk6ySTRv7r+17/7u79nWdYXv/jFH//4v8dvY0+if/u3Dz//+UaCRH+9+/TDh58iUQAoDH6AnlS1pA3nDkfbv//7v//mm1e1t3E4sejhw4efmdOnn342nX6CRAGgMJAoqWqphFVcin2iAKD2iI884VxSpdIM93OFJAoAjQKJkqqWchlxBpAoABQGEiVVLSFRAFgZkCipagmJAsDKgERJVUvlS5TfLQKAjCBRUtVSJSQa//ncc+fO4VEAUECipKqlqkg0vpYLHgUABSRKqloyye+5F75ZskRDj5b+3AJARUCipKolk0E9SpPoHGuLBgtli6tSp5BtCehgEW/L6vRM+4y6rSWtJj1wdItyD13bYjnrmpD9Tk69gcUdxq6tW859UeVGyVu/fU6QKKlqKcGghXg001Joh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RKFVSefRMPD9u8d3Lp9++0f/uill17+6vPPf/nLXwEAyMtXn3/+pZdefvuHP7p1+/b+vYPSG0SAvMwo0XsH93/x/gc//dn29y9ffumll//s298GAMjLSy+9/P3Ll3/6s+1fvP/BvYP7pTeIAHmZUaIH9w/vfrR/6/btn/5s++0f/ugHW28DAOTl7R/+6Kc/2751+/bdj/YP7h+W3iAC5GVGid4PPPqL9z+4dfv2z2/eAgDIy63bt3/x/gcYFFaX2SV6/3BycP/w3sH9/XsHH+3fAwDIy/69g3sH9zEorC5zSRQAAKDJIFEAAIAZQaIAAAAzgkQBAABmBIkCAADMCBIFAACYESQKAAAwI0gUAABgRnJJ9P8Ae6y21Vnjd/sAAAAASUVORK5CYII=" alt="" />
运行Migration, 生成数据库更新代码
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAXIAAABRCAIAAABACbpyAAAIqElEQVR4nO2dYY7cNgyF5yS+/xl6ILdAAwToBdIfARxZJB8pSral8Rt8CDxaiSIp6tk79k4+P3/+t//9DyGEjOJDWSGEjGWMrPz6fMgVPF4fhCQYJiuPR/J9MKtkUSgr88KskkWhrMwLs0oWhbIyL8wqWZRmWdm2TTZyA1wBs0oW5Y+sbMWrbCkPjvbKSrkBtvMr6Ifs3Gqh1edRXGeZskIW5XS1UgrKbm/RXeylagNUdoKonUfJyiiuExEJZYUsSlJW9vMGU2UloQjBRmyEskLIs9SyEvklqOz/+0DKirRj/ZpjjaqmUEdt55flsyWLYHjQQ2AZxG4lpIKyQhZFv1op327GpUfZ4l6tlNssfmC5pPqDfXbtAEUDdoKWg85XUFbIoiRlpXprfbYiW8DJPygr+DwflJVd6IhqUL3QsEKzogCx47WhrJBFyciK3A/uR7bDr1YsWq9WIi1XyEokHMoKWRTlBvPxM3WLqjsB32CWx7KndEDasfwssXy2jKhTW93KRuCM1UFOZ0Uhs0rIQrz0KdtNqOeELJdVQn7zUlnZvaueGVgxq4Ts/L6VyXm8PghJwG+HI4QMhrJCCBkMZYUQMhjK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ZGacj2xBDU0iK261BWXFDWFg7GlZSRyk/cH5sXrmZCWXZzIt6Jv3q3bZcuxVebaxRskOEcvSEzB7xdFtP9dr09RWNxCaHAWicJEWLH8igeA+2/mlVoLaQboXLA/LGdUUSFFr9ZOLWP5xuKrsHrdDCFleVnb7yuIpO4S8nG+QFULIVFBWCCGD+SMr//74ixBC+vkfCzH54b3N+FgAAAAASUVORK5CYII=" alt="" />
会在项目中生成Migrations文件夹,以及2个代码文件。
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAARcAAAA9CAIAAAAI8bpnAAAH9UlEQVR4nO2dv28bNxTH85cQSIAgkDR68CrXywEdutqbPAjIllvaSV4CwUAUIEVxCWINGSrDyNQIgXBAmkFIIaCToS66odVfEC9pF84d7tcj+UjeHUUpkd8XD0FE3Xu8k/g5PvJI+R436sGDB9Pp1HyMTt9VljZEEgUsVxAlcmFRFIfY/+OQMcZYGIsHmCOAI2HtUpAsdPYG6Y7rnvntxgjxjVBEIn0LslDkIqKIdEfkkSIS6Y6IKCKRXEUUkUiuIopIJFcRRSSSq3ZA0cXFBc3RkfZJ26bo4uLi6dPhv1/+K4woIn3r8k6R1O0UCKUv9RTFIbYwIImCbMFBEgVwOUJjbSoO6Q6rHkWr1apuBSkqBtNTFASB1L7ThTfujV5cEEQiuakGRYvFot1u163AhaIwFDGKQxaGmwCAKCJtUlUpWiwWDx8+ZIzVrcCFoiiJwzKrS6IgLdEuGw2iCL4bhkGxjFRcVKpZYwqWn+a1xmEaVVi7Wh5Ha1FJvCJFBUK1KLIun6tAES8xSiFCFl/HYd6ay1ETj0Mk88MIxOKAwRIYnhXvQ7RJpCoUQYRqUfTkyRMzRR9//2ilKIenaLoKCfkBgpeUs5Xdj56iJAoAHEp10pGUEZJKWSiSEKpF0du3b80UvXjxs52ilJK4QKU+RSUexaFuFBVRKaMjcc7NFK1Wq3a7zURVD71arcwUnZycVKAo60nAi4oZneIh5GnWjK5I43CKuMQv6Q7L7/Oi09NTM0j//L22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V6VYnT+CoEqXAJLTyLBEbqaCESSd1KHIfZz5jBs0FnF9DfNgOVi6cnTO6jp4dERvo0EFw6AD0pa1fkh6JdIEQi7Uy0jm5fJY2C7DdUUmMRRSSSq4giEslV926WazIyMhcjisjIXI0oIiNzNaKIjMzVvFB0df1u5xdGRrY180LRo0ePHEGyzooY3eeDo/wxydHwfd3ax/3McTbssuPBzM9H7zU42XbNC0WMsVar3RiklBPrXlfcfTbsMtYbly8H41q1T3rQfcM26RE5+2i+KIpevmkMEq+21xXznQ+OHBnw2tCJov00XxTdLNeNQeLV9hchvrNhl/Uv0bCzYTfP8nLMJj12PDjvp4Xd83naEYkv80afu3fPh3khRGICC3tnx4z1L5fry7M83NkEBs9fysGN5yZdUZm19sbqS7KtmkeKbpbrH38atFrtPxZ/1XLn1fa6Ir6zYRcfCIE8rRyQTHpZg07HQil+OjYy9/fnx8xCkdroJzbwKp5bYfPBkVjLuJ8dTLYL80jR1fW7VqsdvXxT133zfZFYfnmWtlptZyIXCnBakQA527if9zHG4FXPTX+Zs2EX77LItmG+KGqM0M1yzSvsddX4asZFO6GorHQ+OPJM0XJ9k/WTlNHtwDzO0TVD6Ga55pq9rpXcx32GzNFJWZM5eauY0QFix32ktxn3s3l2IU+zZnRVzk3J6HJ7f35MPdL2zQtF9+/fb4xQavWfEQEDg/XyeVFZiN7jzRSVuRmYXQAJ21kfc89H/Ef9XtYX5fMN2tmFWucGphPK1FEzuULm07xQ5IjQV22GaUCyu2q0jq6eXZ41Wg9BttdGFFUxsKSIOiIyxYgiMjJXI4rIyFyNfneBRHLV/zXg0MEU14INAAAAAElFTkSuQmCC" alt="" />
修改代码, 在Seed方法中,添加程序的初始化数据, 添加3条记录
protected override void Seed(SchoolContext context)
{
// This method will be called after migrating to the latest version.
// You can use the DbSet<T>.AddOrUpdate() helper extension method
// to avoid creating duplicate seed data. E.g.
//
context.Students.AddOrUpdate(
s => s.Id,
new Student {Name = "Andrew Peters", Age = 18},
new Student {Name = "Brice Lambson", Age = 29},
new Student {Name = "Rowan Miller", Age = 56}
);
}
执行"Update-Database"命令,生成和代码匹配的数据库
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAjwAAABUCAIAAAAJVXrTAAAJ8ElEQVR4nO2da46cOhBGZyXsf2Uk/yJlA/f+iNRi7Hp8ZRtoek7rKAKPXU/jGk9o+Prz5++fP3/3X7/3X7+3w+fYcjz4x39fX6DzihsAAMzwdSxa+6/fx3K1h0XreDpJLGpG0aTkJT5StAAAVjFetPZFa3oqh6IFAAD/MIqW+OfBV4deaD+q/8Ojqa5XFIxqOqQDq5KrfTxdFC0AgFW4O63j6fHff6Q7rWNRmTnwTJrXrkiummr+iKIFALCK8aIV1Ix9rkT1u5ZGsrkBirUrkvs+upxg70XRAgBYxdROK+CCndak9kDykg2WHisAABD5Mm95f/3YLFrbtikLcbPhMLdH/bbJ3Eh5Wxlde1WybnMgdmOnBQCwlHanJTKwEMc15oOhaAEArOKioqXsjT4VihYAwCrGixbwRAwAgIsZLFoAAADXQ9ECAIDHQNECAIDH8FOK1vvfA/L+FgIA3I777MH5NdSUMCl8eGw6qv9G16n2DFho5ugN78k8w56ZvDdRik8/mNKsvtHCXvv1F+ONKt7W+Pfxvf1y8dHEM6I2P2pASPVaLalYEqhSxTrDgIVyVrE271v3VJexdFdNOi+q510I9zK5sC6XPD8Pzw7+zOpRkvMm88ctWvcGNxh1Qe6vL1oz6ihaY7GiaL0nFK3zJH9g0dqzxxp53Y490w6v33mbYy9MnkmxPWn0e9dexniSTYMVe8wwVm0O5Jjd0oFxnFMLzQyaQ7wgi8Jn8h7EqjGpGvlS3uMZNdAnaClF1bM5FaurSwPYS05THNgz47syapUcMz5K/BV7dEcG5obYJ9A1iX0jRqNv4GDvJl/fYo4ywx2PEuWkvCZNrGvAniAUVZsHoroqzsGQIO9Nn/7fYXv0GMZ2Kikw+ygRG4jG2PVV8mJMcinyV64b583wK7WPrS2p3mE5YxlcuNZ5uHcPxma9PoE14uTTI67bM0wjRP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t5pBcIpWgAAN2Lf8v46btqbvYjX0ojyJJs7myNeB3M/5LUEpagpWqYcz6neu8Byz0EAAChx55eLm2pxeywAAODNufmJGPFOCwAA4AiPcQIAgMdA0QIAgMdA0QIAgMdA0QIAgMcwUrS4bwIAAG4heTWJ+bWknboFAAB3kDwRwytaO3ULAAAuZ7xo7dQtAAC4lvKrSRqoWwAAcBnuTut46j1Aj4oFAABXMl60qFgAAHAxg0WLigUAANfjvprk1bJ3RYuKBQAAt8ATMQAA4DH8D23xcevROPNmAAAAAElFTkSuQmCC" alt="" />
下图是生成的数据库结果:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAc0AAAB+CAIAAADJDt0lAAAfvUlEQVR4nO2df3AT153A9+6vm8l0OtNJ0kyGlKaZdsYT5mrGxifrLr3Ed71hmnSSaXIhJW3g5HRzpVyTOCkXINe5YoIHWcGCq1xkcHHABIwoMYaqEAjhklASUKCxMSQRDgfmp5FBBtuSJRHdH0+7+97bt6v9oZVWq+9n3oC0evve29Xq47dvd9+XywKAI1jW4h/H6OrqisfjK30BpfzBYER8ffDgQfF1X19fNptNJpNjY2PBYKS+vp69frStvr4tKr0P8xwfNtBuVA5dWh5W+gLXSYLBSDAS6evrCwYjXV3dKPF88LpGPn5tFsdx87YR72e99rHW9S0hnU6v9AXi5Q9n4MAAABui17NdXd2nTp06evToQRKkqr6+vq6ubh2eFd9G2+o5RO5jcUF9W5RYSzIsz9dLaxD5FVjpC4yS4H82EG8eiR89evTNI/FgJBKMRIaGhkZViCyvra2trV0eEd9yHCe+LRGpVKpyPbu9uw1PBkoAgIJjwLPia7w/GwxGxsbGxsbGIrFsV1e3mmc5HNSZxTyaeyn0c6Nt9RwfZnsW78+S+RUav9IXiJEEg5Hh4eGRkZGRkZFIJPvmkfibR+L4RtXU8ENDQzEljjTX1jY3P1PbfCQWi8ViW5+pfeaZWuFdqahcz27vboud70teCyevhSdjPTfPrtGp2jCPHZtuv/ZTJXk5JtZWKpL4zRS26EK3Fi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jg9GkKSTX+xTByQRZK9Epp17vf37V721R80uBUqjPrdojQRuGepPiqyKurcRv1uPoz7WTAz9GsdA3gWsC1mPas9LMLaVa8mr4XTl9dlLgQoycZ2P3QlNGu4+/7T7dN6lt7urpmhVCOSI2ZLfNyA7qJG/W58xIDneUYG6NU6BfAsYFvMelZ7WISAd/FkrEeUbOIvPx8/NDd+4FFRsmc6pp/y37Fh0d0zvjNdsUr6hlnmdTChm4pnxl+HeQ4ugzkO8CxgWwrm2bxhEda0LIqf2Tjy8fPn9syO7qj7rGdG/xvfPrz2m/tXTd/RfE/o13f1LL19w6K721/8xr3T7jTTKqAyAc8CtqV498+2LX/5tcW/WLRw3s9+8tjjDz/0YH31d6u+de+0O7/+ta/Ik5lWAZUJeBawLTCPDOAQwLOAbQHPAg4BPAvYFvAs4BDAs4BtAc8CDgE8C9iW/werAsMLu8A6lgAAAABJRU5ErkJggg==" alt="" />
三、创建Controller方法和View
controller代码非常简单,如下:
public class HomeController : Controller
{
public ActionResult Index()
{
var studentRepository = new StudentRepository();
var students = studentRepository.GetStudents();//调用数据层方法,获取数据
return View(students);
}
}
最后,运行起来的效果:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQIAAAC2CAIAAAC9ARTQAAAVlElEQVR4nO2dfYgUZ57HH2iGIbRsHEFbNjrureQ8spGWbfGC8SDZMzaciyJCZMXCo3UzhOXMnZfZ3MqGCXcStmKmw6LhvLs4eNGg2Rgye27jJuyKjMYQZSLJdPTaGDJ4zm3PwDjLOczi0PDcH9X19K+el+qqnp6aGvv7+Ut76uWpp57P81b1/IpxAFoeNtcJAGDugQYAQAMAoAEAHBoAwKEBABwaAMChAQAcGgDAoQEAHBoAwKEBADygBvcnR47bLz6+4tttjDHGEu0Llq94vOvl1y5f+/o+r5w6sL23vzTbCdVRyjCZjNU7FykJzmguvVRJtYcgmVmZHvmnrevbGFvyZ+t/+/lIBOl+sKmvwY1Lp1Ym2xLtHX9nvzNyd5JzPnl3bODsW2sf6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jRNA1Ev1SJERYidjc0oDQe2L0ZEa1pxCuuTnoos6upQrHcZ9tlt3SK4Fy0QMxAg6pL6XSahtxqQAPd1E0zWwPaMOoCSM70FK3GnES0rpVFacznjfMu3dRyLp3KWlYfGQDk3B4R7c/QyZOAGmS9BZ1uRo8gBcDzXospoJ34SEezNKARrT1x/gz6NXCKliP4125q8zCN5rXnKbIac04EP1S3IVt6ip0kibNX1rLkINdKWDhxTDWYnKhr6acPGEsVikVxioyV984WyOHrlM8maOLbBc437s062WSRklBPD6ABBe8UxRG8UxQx0CCOQIOIgQZxBBpEDDSII9AgYqBBHIEGEQMN4gg0iBhErYspEeSbcwpowBGuC0ADDg0ANOA+GgSLfQYeBKIscPHEqAEArQM0AAAaAAANAODQAAAODQDg0AAADg0A4NAAAA4NAOCc/z8vpzpWwiIIpwAAAABJRU5ErkJggg==" alt="" />
四、正式项目开发中的困境
假设一个在一个真实的项目环境里面,你和甲一起开发整个项目, 其中甲负责EF数据访问部分,你负责MVC逻辑和显示部分。
在真实项目中当然远远不止Student一个表,可能有上百个,还有很多的存储过程。
你在开发的过程中,常常运行遇到数据层的bug,不断抛出异常,导致你的开发无法顺利进行下去。你常常需要停下来,调试到数据层,找到bug原因,然后告诉甲赶快改好,你还等着开发页面上的一个ajax特效。
随着不断的出现的数据层bug, 眼看项目结束日期越来越近,你已经焦头烂额,但是却还有很多功能没有完成,老板也开始怀疑你的能力..........
五、解耦合,脱离数据层
你对甲已经忍无可忍了,你的命运为什么要掌握在甲的手中,要想办法摆脱甲。
好吧,我要依赖在抽象的接口上,而不是直接依赖甲开发的数据层。
首先我们可以创建一个接口:
public interface IStudentRepository
{
IEnumerable<Student> GetStudents();
}
然后, 创建一个集成这个接口的类,这个类并不访问数据库,但是提供我们开发页面所需的数据。
public class StubStudentRepository:IStudentRepository
{
public IEnumerable<Student> GetStudents()
{
return new[]
{
new Student {Id = 1, Name = "Sam", Age = 14}
};
}
}
好了,一切都准备好了, 开始改造我们的Controller代码
public class HomeController : Controller
{
public ActionResult Index()
{
IStudentRepository studentRepository = new StubStudentRepository();
//IStudentRepository studentRepository = new StudentRepository();//注释掉访问数据层的代码,用Stub类代替
var students = studentRepository.GetStudents(); return View(students);
}
}
由于,我们写的Stub类,不访问数据库,而且不需要有复杂的逻辑,只是提供我们Controller代码运行所需要的基本数据就可以了。这样你的开发就依赖在你自己写的更加可靠的Stub类上了。
最后,你叫来甲,对他说:哥们, 我为我们之间的依赖,创建好了接口,你以后的数据访问代码,都从这个接口继承吧。
从此,这个项目开发变成了另外一种样子,你再也不抱怨甲总是写不稳定的代码了(因为你不依赖他了),你总是能通过写一些Stub类,返回不同的值,来测试你的界面代码。
六、实例化,可恶的实例化
在Controller的代码中,我们有下面2行代码,如果是发布的情况下,我们使用下面一行,开发过程中,使用上面一行。
但是,这个项目代码太多了,难道到发布的时候,要我一个个找出来,都换成真实的甲的数据库访问层的类的实例吗?
IStudentRepository studentRepository = new StubStudentRepository();
//IStudentRepository studentRepository = new StudentRepository();//注释掉访问数据层的代码,用Stub类代替
七、使用Autofac依赖注入
这个时候,就是Autofac大显身手的时候了,
首先,我们改造Controller代码:
public class HomeController : Controller
{
private readonly IStudentRepository _studentRepository;
//由构造函数来提供Controller的依赖IStudentRepository
public HomeController(IStudentRepository studentRepository)
{
_studentRepository = studentRepository;
} public ActionResult Index()
{
var students = _studentRepository.GetStudents(); return View(students);
}
}
然后, 修改Global.asax,
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
//Autofac初始化过程
var builder = new ContainerBuilder();
builder.RegisterControllers(typeof(MvcApplication).Assembly);//注册所有的Controller
//开发环境下,使用Stub类
builder.RegisterAssemblyTypes(typeof (MvcApplication).Assembly).Where(
t => t.Name.EndsWith("Repository") && t.Name.StartsWith("Stub")).AsImplementedInterfaces();
//发布环境下,使用真实的数据访问层
//builder.RegisterAssemblyTypes(typeof(MvcApplication).Assembly).Where(
// t => t.Name.EndsWith("Repository")).AsImplementedInterfaces(); var container = builder.Build();
DependencyResolver.SetResolver(new AutofacDependencyResolver(container)); //其它的初始化过程
........
}
}
当我们使用下面这行代码的时候,所有的controller就都是使用Stub类的实例
//开发环境下,使用Stub类
builder.RegisterAssemblyTypes(typeof (MvcApplication).Assembly).Where(
t => t.Name.EndsWith("Repository") && t.Name.StartsWith("Stub")).AsImplementedInterfaces();
当我们使用下面代码的时候,所有的controller就都用的是实际的数据访问类实例。
//发布环境下,使用真实的数据访问层
builder.RegisterAssemblyTypes(typeof(MvcApplication).Assembly).Where(t => t.Name.EndsWith("Repository")).AsImplementedInterfaces();
八、总结
关于Autofac的详细具体用法,大家可以上官方网站: http://code.google.com/p/autofac/
这里也有文章,对Autofac用法有总结 AutoFac使用方法总结
对于Autofac内部实现的机理, 这里有一篇文章,IoC容器Autofac(3) - 理解Autofac原理,我实现的部分Autofac功能(附源码)
对于Autofac在Asp.net MVC中是如何实现依赖注入的分析,这里有篇文章 分析Autofac如何实现Controller的Ioc(Inversion of Control)
IoC容器Autofac - Autofac + Asp.net MVC + EF Code First(转载)的更多相关文章
-
IoC容器Autofac(5) - Autofac在Asp.net MVC Filter中的应用
Autofac结合EF在MVC中的使用,上一篇IoC容器Autofac(4) - Autofact + Asp.net MVC + EF Code First(附源码)已经介绍了.但是只是MVC中Co ...
-
转载——Asp.Net MVC+EF+三层架构的完整搭建过程
转载http://www.cnblogs.com/zzqvq/p/5816091.html Asp.Net MVC+EF+三层架构的完整搭建过程 架构图: 使用的数据库: 一张公司的员工信息表,测试数 ...
-
ASP.NET MVC+EF框架+EasyUI实现权限管理系列(22)-为用户设置角色
ASP.NET MVC+EF框架+EasyUI实现权限管系列 (开篇) (1):框架搭建 (2):数据库访问层的设计Demo (3):面向接口编程 (4 ):业务逻辑层的封装 ...
-
ASP.NET MVC+EF框架+EasyUI实现权限管理系列(1)-框架搭建
原文:ASP.NET MVC+EF框架+EasyUI实现权限管理系列(1)-框架搭建 ASP.NET MVC+EF框架+EasyUI实现权限管系列 (开篇) 前言:这篇博客开始我们便一步一步的来实现这 ...
-
[转帖]Asp.Net MVC EF各版本区别
Asp.Net MVC EF各版本区别 https://www.cnblogs.com/liangxiaofeng/p/5840754.html 2009年發行ASP.NET MVC 1.0版 201 ...
-
ASP.NET MVC+EF框架+EasyUI实现权限管理系列(24)-权限组的设计和实现(附源码)(终结)
ASP.NET MVC+EF框架+EasyUI实现权限管系列 (开篇) (1):框架搭建 (2):数据库访问层的设计Demo (3):面向接口编程 (4 ):业务逻辑层的封装 ...
-
ASP.NET MVC+EF框架+EasyUI实现权限管理系列(23)-设置角色遗留问题和为权限设置角色以及EasyUI Tabs的使用
ASP.NET MVC+EF框架+EasyUI实现权限管系列 (开篇) (1):框架搭建 (2):数据库访问层的设计Demo (3):面向接口编程 (4 ):业务逻辑层的封装 ...
-
ASP.NET MVC+EF框架+EasyUI实现权限管理系列
http://www.cnblogs.com/hanyinglong/archive/2013/03/22/2976478.html ASP.NET MVC+EF框架+EasyUI实现权限管理系列之开 ...
-
ASP.NET MVC + EF 利用存储过程读取大数据,1亿数据测试很OK
看到本文的标题,相信你会忍不住进来看看! 没错,本文要讲的就是这个重量级的东西,这个不仅仅支持单表查询,更能支持连接查询, 加入一个表10W数据,另一个表也是10万数据,当你用linq建立一个连接查询 ...
随机推荐
-
js 时间格式化 代码
Date.prototype.Format = function (fmt) { //author: meizz var o = { &quo ...
-
Erlang 参考资料
Erlang 官方文档 Distributed Erlang Erlang 教程中文版 %设定模块名 -module(tut17). %导出相关函数 -export([start_ping/1, st ...
-
shell 外部传入jmeter脚本线程数,rampUp时间,持续运行时间
jmeter参数化部分参考上一篇 shell参数说明:$1线程数,$2:全部并发数rampup时间,$3:脚本持续运行时间,$4:每次脚本循环持续时间 $5:所以循环持续时间 #!/bin/bash ...
-
Python得到前面12个月的数据,Python得到现在时间 前一年的数据,
#Python 实现得到现在时间12个月前的每个月 # 假设现在的时间是2016年9月25日 #得到现在的时间 得到now等于2016年9月25日 now = datetime.datetime.no ...
-
Fedora下phpMyAdmin的安装和配置
phpMyAdmin主要用于以web界面形式管理mysql.其在Fedora下的安装方法如下: 1. yum install phpMyAdmin 利用yum安装的phpMyAdmin,其路径如下: ...
-
Java数据结构和算法(十五)——无权无向图
前面我们介绍了树这种数据结构,树是由n(n>0)个有限节点通过连接它们的边组成一个具有层次关系的集合,把它叫做“树”是因为它看起来像一棵倒挂的树,包括二叉树.红黑树.2-3-4树.堆等各种不同的 ...
-
基于docker实现哨兵集群部署
简单dockerfile文件,用于演示sentinel哨兵故障转移FROM centos:latest MAINTAINER BIXIAOYU RUN groupadd -r redis && ...
-
cp2102 驱动 win7x64 -2018
试了好多种网上的驱动,都不行,要么是报错要么是安装没反应 之后意外遇见驱动官网?里面真全 url:https://www.silabs.com/products/development-tools/s ...
-
mysql数据库-定义函数-存储过程写法
------------- mysql 定义自定义函数写法 DELIMITER $$ USE `iwmsdb`$$ DROP FUNCTION IF EXISTS `F_WM_DBNAME`$$ C ...
-
关于js事件执行顺序小技巧
js事件执行顺序是js中一个老生常谈的一个话题, 聊这个话题之前我们先谈谈怎么给页面元素绑定我们需要的事件 1.给页面元素绑定事件 a)直接在元素上面加上需要绑定的事件,如 <button ty ...