Set IReturn<T> dynamically

Hello,

My dto’s are in a separate assembly without any reference to ServiceStack (I’m setting ServiceStack attributes dynamically). I would like ‘to do the same’ with IReturn interface (I want my generated client dto’s implementing this interface) and keep my dto project free from ServiceStack references.

How can I achieve this nicely (dynamically adding the interface does not seem a very a good idea … and requires external frameworks) ?

Thanks in advance,
Olivier

It’s impossible to add Interfaces to an existing .NET class, but even if it were it would defeat the purpose of the IReturn<T> and IReturnVoid interface markers which is to enable a Typed API for generic Service Clients, which would not be available at compile time if they were dynamically added.

ServiceStack DTOs only need to reference the dep and impl-free ServiceStack.Interfaces.dll, which allows your clients to have the minimum dependencies to be able to call any remote ServiceStack Service. I’d strongly recommend against trying to define your ServiceStack Service Contract without trying to reference ServiceStack.Interfaces, which will only result a less valuable and less knowledgeable Service Contract with no real gain which is contra to the goals of defining a rich Service Contract.

Thank you very much ;).

To give you the full picture, I wanted the dto’s to be sent over rabbitMQ (through EasyNetQ, we need topic exchange) and to be shared with existing asp web api’s.

That still shouldn’t preclude a reference to ServiceStack.Interfaces.dll which is a Profile 328 PCL dll which can be referenced in .NET’s most popular platforms.