我正在尝试使用WebAPI BindParameter绑定到某个对象类型的父级。我能够绑定到对象本身(SomeObject),但不能绑定它的父(SomeOtherObject)。这将导致我必须对SomeObject的所有可能的继承者进行特定的BindParameter调用。有没有更好的方法来绑定允许我完成此操作的参数类型?
粘合剂:
GlobalConfiguration.Configuration.BindParameter(typeof(SomeObject), new SetTrackerModelBinder());
GlobalConfiguration.Configuration.BindParameter(typeof(SomeOtherObject), new SetTrackerModelBinder()); //Does not work.
对象结构:
public class SomeObject:SomeOtherObject{
}
public class AnotherObject:SomeOtherObject{
}
public class SomeOtherObject{
}
行动:
public void PostStuffs(SomeObject value) {}