Binding to a Derived Type
绑定派生类型
Although we have focused on interfaces (since that is most relevant in MVC applications), we can also
use Ninject to bind concrete classes.
我们关注这个接口(在mvc 应用里 是意义重要的), 还可以 用Ninject 去绑定这个具体的类
In the previous section, we showed you how to bind a concrete
class to itself, but we can also bind a concrete class to a derived class.
前面章节,已经展示过 怎样去绑定一个具体的类,但是现在还绑定了一个派生类。
Listing 6-15 shows a ShoppingCart
class that has been modified to support easy derivation, and a derived class, LimitShoppingCart, which
enhances its parent by excluding all items whose value exceeds a specified price limit.
ShoppingCart 被修改成支持简单的派生,
LimitShoppingCart, 提高 它的父类, 排除 所有物品 ,这些物品 超过 一个特别价格限制。
时间: 2024-10-19 02:53:04