public class UserAuthorizeAttribute : FilterAttribute, IAuthorizationFilter
{
public IUserService UserService{get;set;}
}
如何对UserService进行依赖注入?
public UserAuthorizeAttribute()
{
IApplicationContext ctx = ContextRegistry.GetContext();
IUserService userService = ctx["userService"] as IUserService
}
[UserAuthorize()]
public class WebForm1
{
}
不知道是不是你要得答案
更一步
WebForm1也可以配置成Spring Object
spring害了不少人啊,java的.net的全给害了