我的global.asax看起来像这样
Imports Castle.Windsor
Imports Castle.Windsor.Configuration.Interpreters
Public Class MvcApplication
Inherits System.Web.HttpApplication
Implements IContainerAccessor
Private Shared IoC As IWindsorContainer
Shared Sub RegisterRoutes(ByVal routes As RouteCollection)
routes.IgnoreRoute("{resource}.axd/{*pathInfo}")
' MapRoute takes the following parameters, in order:
' (1) Route name
' (2) URL with parameters
' (3) Parameter defaults
routes.MapRoute( _
"Default", _
"{controller}/{action}/{id}", _
New With {.controller = "Home", .action = "Index", .id = ""} _
)
End Sub
Sub Application_Start()
RegisterRoutes(RouteTable.Routes)
IoC = New WindsorContainer(New XmlInterpreter)
End Sub
Public ReadOnly Property Container() As Castle.Windsor.IWindsorContainer Implements Castle.Windsor.IContainerAccessor.Container
Get
Return IoC
End Get
End Property
End Class
如何从任何模型类中访问Container属性?
有没有一个类可以继承给我视图中的“Application”属性,这样我就可以
IoC=应用程序。项目(“容器”)。..