I have a library with some objects that I use both from C# and JavaScript. There are several objects, let’s call one of them Foo, with the same basic implementation in C# and JavaScript. When I want to transmit an object of this type from the server to the browser, I simply call Foo.ToJson() to serialize this object to JSON and then revive the object on the browser side with a safe eval() operation.
This is all well and good, but the library is becoming complex and the need to keep the JavaScript and C# code bases synchronized is increasingly difficult and error-prone. I’m interested in ideas for simplifying this architecture or making it easy to maintain. Thoughts?
You could look at using script#: http://projects.nikhilk.net/ScriptSharp
Since your classes are all coded in C#, you could reuse the same .cs file for both the server and client projects. that way, when you make changes, it’s automatically compiled into the javascript 🙂