asp.net web api odata - Is there a way to prevent addition of default ODataMediaTypeFormatters to configuration? -


i trying customise behaviour of standard odatamediatypeformatters , have done wrapping them in type extends mediatypeformatter. e.g.

var formatters = odatamediatypeformatters                    .create(serialiserprovider, deserialiserprovider)                    .select(formatter => new wrapper(formatter));  config.formatters.insertrange(0, formatters); 

after webapi configuration method has executed config.formatters contains 12 items (7 of wrapped formatters).

however, when response being serialised config.formatters contains 17 items standard odata formatters have been re-added @ point. relevant standard formatter used in preference wrapped version.

does know when re-addition happens , if/how can prevented?

i figured out when realised formatters not re-added globalconfiguration.configuration.formatters, controllercontext.configuration.formatters.

the odatacontroller annotated odataformattingattribute. checks see if controller's configuration contains odatamediatypeformatters and, if not, re-adds them.

when performs check looks wrapped formatters using decorator.getinner, having wrappers implement idecorator solved problem.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -