[.net] Good ways to map webserver objects

Started by
1 comment, last by Justaddwater 16 years, 10 months ago
Hai I find myself in a problem more often then not that involves some hacky code to fix. I'm just wondering if anyone has come up with a elegent solution to the web service objects conversion. Example: I have a assembly MyObjects.dll, I have a webservice MyService.asmx, I have a winforms app consumeing that service MyApp.exe Both MyApp and MyService use the same MyObjects.dll to get a "Sample" object But since MyService returns it from a web call I now need to map it to another instance of Sample to use it in my app outside of the DAL area. I end up writeing dumb code like:

MyObjects.Sample ConvertSample(MyService.Sample sampleToConvert)
{
MyObjects.Sample x = new MyObjects.Sample();
x.Name = sampleToConvert.Name;
return x;

}

Has anyone come up with a nicer way of doing this?
Advertisement
What happens if you just try to use the object without making a copy? Does it throw an exception later on?
Its not the same type.

So if I have a assembly DataAccess.dll that does my web call and it references my MyObjects.dll to get a sample and passes that to my UI, its a different type then myService.asmx returns, even though they both are getting it from MyObjects.dll.

This topic is closed to new replies.

Advertisement