有没有人设法在Castle Windsor的MVC 4中做以下事情?我正在观看有关六角形建筑和视频的视频后进行实验。试图更多的域驱动 - 即专注于对象之间的消息。
public class UserController : Controller, ICreatedUser
{
public IUserCreator _creator;
public class UserController(IUserCreator creator)
{
_creator = creator;
}
public void Create(CreateUserModel model)
{
_creator.Create(model);
}
public ViewResult Successful(User user)
{
return View(user);
}
public ViewResult Unsuccessful()
{
return View();
}
}
public interface ICreatedUser
{
ViewResult Successful(User user);
ViewResult Unsuccessful();
}
public class UserCreator : IUserCreator
{
private ICreatedUser _createdUser;
public class UserCreator(ICreatedUser createdUser) // I want the controller injected here
{
_createdUser = createdUser;
}
}
我知道其中一个问题是ICreatedUser上的“ViewResult”对于UI来说太具体了 - 可能是C#的限制。