Pergunta

Given the fact that I have a fully dynamic object model, that is, I have no concrete classes defined anywhere in code, but I still want to be able to create WCF DataContracts for them so I can use them in operations. How can I achieve this?

My concrete class "Entity" implements ICustomTypeDescriptor which is used to present the various properties to the outside world, but my expeimentation with WCF suggests that WCF does not care about ICustomTypeDescriptor. Is this correct or have I missed something?

Is this possible? It cannot be so that the only way to create a DataContract is to actually have a concrete harcoded class, can it?

Foi útil?

Solução 3

Things evolve :-) Thanks to the excellent blog series by Alex D James its very easy to implement this.

Outras dicas

you may use untyped service and message contract IIRC http://geekswithblogs.net/claeyskurt/archive/2008/09/24/125430.aspx

You might try System.Reflection.Emit.

Its quite tricky, but essentially you will just build a custom run-time type, with decorated data contract attributes. It gets tricky when creating encapsulated properties with PropertyChanged notifications, but in your service layer you can just get away with auto properties which are a lot easier.

This dated, but still very relevant link should get you going in the right direction. http://drdobbs.com/184416570

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top