我目前正在重构我们的后端,并且在此过程中,我删除了ServiceLocator上的依赖关系。 但是!现在这已经给我搞清楚怎么做依赖注入,当需要注射的种类,从Web.config中 目前,具体的情况下被拉的头痛是这样的:在type =“”属性上使用依赖注入
<system.identityModel>
<identityConfiguration>
<claimsAuthenticationManager type="MyNamespace.MyClaimsAuthenticationManager, MyAssembly, Version=1.0.0.0, Culture=neutral" />
<claimsAuthorizationManager type="MyNamespace.MyClaimsAuthorizationManager, MyAssembly, Version=1.0.0.0, Culture=neutral" />
<securityTokenHandlers>
<remove type="System.IdentityModel.Tokens.SessionSecurityTokenHandler,System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<add type="System.IdentityModel.Services.Tokens.MachineKeySessionSecurityTokenHandler,System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<securityTokenHandlerConfiguration maximumClockSkew="5"></securityTokenHandlerConfiguration>
</securityTokenHandlers>
</identityConfiguration>
</system.identityModel>
这里的类型MyClaimsAuthenticationManager和MyClaimsAuthorizationManager是需要注入它们的依赖项的。
该项目在.NET 4.5下运行,目前使用Ninject作为依赖注入部分。
感谢您的回答 - 我会马上购买您的书籍,但它不能作为Kindle电子图书提供:o必须等待蜗牛邮件发送:-) – 2014-10-27 09:43:43
报废,找到电子书在万宁自己的网站上。谢谢,周一愉快 – 2014-10-27 09:51:54