web api model binding to an interface
I'm trying to bind a controller action to an interface but still maintain
the default binding behavior.
public class CoolClass : ISomeInterface
{
public DoSomething {get;set;} // ISomeInterface
}
public class DosomethingController : ApiController
{
public HttpResponseMessage Post(ISomeInterface model)
{
// do something with model which should be an instance of CoolClass
}
}
The consumer of my service knows nothing of CoolClass so having them add
"$type" to the Json they are passing would be a hack in my opinion. I'd
like to be able to handle it in the service. If I specify CoolClass as the
action parameter it works fine.
No comments:
Post a Comment