In Silverlight, is it possible to honor the ToString() method of a domain object returned from a service call?
In our domain, we override the ToString method on all our domain types.
However, when returning those domain objects in response to a Silverlight service request, the functionality of ToString is lost. ToString() just returns the namespace description of the object as it is imported from the service. My guess is that the domain proxy created by the service reference doesn't include the ToString logic.
Is it possible to get this to work without having to re-implement ToString on the Silverlight client?
Update: BTW, this is so I can bind to the whole object and have the string description honored. I have a collection o开发者_开发技巧f domain objects coming back from a service. I would like to set the ItemsSource of a UI collection to a list of these domain objects and not have to re-create the ToString logic locally.
The proxy doesn't generate a member part for the contract for the ToString() method, because ToString() isn't part of the ServiceContract. Not just that though, I'm not confident that the proxy classes that are generated, intelligently override Object.ToString() when they are created. Could you not add a descriptive method, something like GetDescription() which will be created in the proxy?
If not, could you not just override the method in the proxy (it should be generated as a partial) and provide a client-specific implementation?
精彩评论