biofractal - 2009-03-16

Hi

I am trying to get NeoDatis to work from a silverlight client.

Silverlight 2 now supports sockets so I don't see any reason why a silverlight client should not be able to serialize domain objects over a TCP/IP connection, from the silverlight client to its host web site server.

I think this would greatly reduce the complexity of the client code. The only way I know to get an ODB working right now is to write a specific data-layer WCF web service. This is not a good option. I love NeoDatis and have seen how much effort is saves me elsewhere so I want the same advantages in my Silverlight applications as well.

OK, so what I need to do is port NeoDatis to Silverlight :-) Can it be done?

Well I have spent the last few days going over your code trying to do just that. I have finally hit a brick wall just a few feet short of the finish post. So I thought I would share with you what I did and then get down on my knees and beg for your help (more on that later).

Remembering that I only need the NeoDatis client to work in Silverlight, here is what I did.

I started with your ODB interface, the main client interface, and worked my way out. I included each class required for this interface fixing the problems as I went. These classes and interfaces led to others fanning out until I eventually converted 149 classes. The main problems were the lack of Silverlight support for some well used classes and attributes. For example Silverlight does not support:

- ArrayList
- Hashtable
- SortedList
- NameValueCollection

I wrote identically named generic versions of these classes to take their place. So my ArrayList class is just a wrapper for the List<object> and the Hashtable class a wrapper for Dictionary<object, object> and so on. In this way I managed to solve pretty much all of the List based issues.

I ran into more trouble when I realized that the [Serializable] attribute is not supported in Silverlight. I simply replaced this with the WCF [DataContract] attribute and soldiered on.

Well I could go on, but to cut a long story short I finally hit the wall with Nedatis.Odb.SupportClass. This was full of problems not least the threading and the binaryserializer stuff. Silverlight does not support binary serialisation but here is an interesting link:

http://www.lhotka.net/weblog/SilverlightSerializer.aspx

So, I have a dream. My dream is to be able to serialize my domain objects from a Silverlight using NeoDatis. Not only would that be a very cool thing to do but it would also save about 50% of the coding effort currently required to serialize domain state data from a Silverlight client to its host web server.

And given the current excitement over all things Cloudy and SaaS then NeoDatis being the first Silverlight compliant ODB may just give the guys at db4o something to worry about ;-)

What do you think?

biofractal