.NET to Javascript compiler

Remoting API

"Remoting" group describes different development states and aspects of remoting interfaces implementation.
TestRemotingApp implements client part and a TestWebSite implements server site (and have to be started to run this samples). The download contains all needed projects.
Client uses "Proxy" object to communicate with the server. The communication is asynchronous. JScriptSuite provides two pattern to communicate with server.
success/failed pattern
On requests client specifies:
  • input parameters - data will be sent to server
  • success delegate - code will be called if request is succesfully completed. The success delegate recieves server result (see below)
  • failed delegate - code will be called if error occures.(see below)
task/await pattern
On requests client specifies:
  • input parameters - data will be sent to server
  • Task<Result> return type, to recieve server result (see below) after await
  • try/catch to handler exception (see below)
For example: "Add Service Referece..." VS context menu item adds autogenerated interface to WCF service:
interface IServer
{ // auto generated WCF interface
  string Execute(string input);

The Client proxy can be defined as such:
[ServiceContract(ServiceType = typeof(IServer))]
public interface IClientProxy
  IDisposable Execute(string input, Action<string> success, Action<Exception> failed);
  // or/and
  Task<string> Execute(string input);
JScriptSuite analyzes the method signatures and generates the proxy object which is based on ClientProxy and implements the abstract Execute methods.
In this sample IClientProxy declares two prototypes to execute "Execute" - server method. Public properties and fields will be sent to/received from server (see sample). Their names will be compared with properties in auto generated WCF types which have been referenced by "IServer".
Communication via Json and Soap is already supported. Developers can add any other formatting.

GenericProxy sample allows to communicate with the server without DTOs. Copying DTO to ViewModel Object is not needed.
[ServiceContract(ServiceType = typeof(Services.WebServiceSoap))]
public interface IServiceClient
    IDisposable GetPersons<TPersonsList, TPerson>(
        IEnumerable<IPerson> persons,
        Action<TPersonsList> success, Action<Exception> failed)
        where TPersonsList : IList<TPerson>, new()
        where TPerson : IPerson, new();

    Task<TPerson[]> GetPersons(IEnumerable<IPerson> persons);
IPerson interface defines properties which will be sent to/recieved from server. Client can send/recieve ViewModel Objects directly.
CreateClient().GetPersons<ObservableList<Person>, Person>(request,
            delegate(ObservableList<Person> response)
                ShowResult(response, null);
            delegate(Exception e) { ShowResult(null, e); });
or with task/await
    ShowResult(new ObservableList<Person>(await CreateClient().GetPersons(request)), null);
catch(Exception e)
    ShowResult(null, e);
© 2009 JScriptSuite. All rights reserved.