// This JavaScript was automatically generated by
// Jayrock.JsonRpc.Web.JsonRpcProxyGenerator, Jayrock, Version=0.9.12915.0, Culture=neutral, PublicKeyToken=null
// on Thursday, June 20, 2013 at 5:06:54 AM (Pacific Daylight Time)

// Proxy version 2.0

var DemoService = function()
{
    var nextId = 0;

    var proxy = {

        url : "http://www.raboof.com/projects/jayrock/demo.ashx",
        rpc : {
            
            /* Return the sum of two integers. */
            
            "add" : function(a, b, callback) {
                return new Call("add", [ a, b ], callback);
            },
            
            /* Returns the cookie names seen by the server. */
            
            "cookies" : function(callback) {
                return new Call("cookies", [ ], callback);
            },
            
            /* Increments a counter and returns its new value. Demonstrates use of session state. */
            
            "counter" : function(callback) {
                return new Call("counter", [ ], callback);
            },
            
            /* Returns the string from encoded bytes (transmitted as a Base64 string). */
            
            "decode" : function(bytes, encoding, callback) {
                return new Call("decode", [ bytes, encoding ], callback);
            },
            
            /* Echoes back the text sent as input. */
            
            "echo" : function(text, callback) {
                return new Call("echo", [ text ], callback);
            },
            
            /* Echoes back the arguments sent as input. This method demonstrates variable number of arguments. */
            
            "echoArgs" : function(args, callback) {
                return new Call("echoArgs", [ args ], callback);
            },
            
            /* Echoes back the arguments as an array of strings. This method demonstrates working with variable number of arguments. */
            
            "echoAsStrings" : function(args, callback) {
                return new Call("echoAsStrings", [ args ], callback);
            },
            
            /* Echoes back the given GUID. This method demonstrates working with an argument typed as System.Guid. */
            
            "echoGuid" : function(id, callback) {
                return new Call("echoGuid", [ id ], callback);
            },
            
            /* Echoes back the object sent as input. */
            
            "echoObject" : function(o, callback) {
                return new Call("echoObject", [ o ], callback);
            },
            
            /* Echoes back the date/time sent as parameter. */
            
            "echoTime" : function(time, callback) {
                return new Call("echoTime", [ time ], callback);
            },
            
            /* Returns the bytes of a string in a given encoding that are transmitted as a Base64 string. */
            
            "encode" : function(s, encoding, callback) {
                return new Call("encode", [ s, encoding ], callback);
            },
            
            /* Formats placeholders in a format specification with supplied replacements. This method demonstrates fixed and variable arguments. */
            
            "format" : function(format, args, callback) {
                return new Call("format", [ format, args ], callback);
            },
            
            /* Returns information about the author. Demonstrates how a Hashtable from the server is automatically converted into an object on the client-side. */
            
            "getAuthor" : function(callback) {
                return new Call("getAuthor", [ ], callback);
            },
            
            /* Returns a server-typed object representing a couple. Demonstrates to returning server-typed objects. */
            
            "getCouple" : function(callback) {
                return new Call("getCouple", [ ], callback);
            },
            
            /* Returns a data-bound DataGrid to the client as HTML. */
            
            "getDataGrid" : function(callback) {
                return new Call("getDataGrid", [ ], callback);
            },
            
            /* Returns the Northwind employees as a DataSet. */
            
            "getDataSet" : function(callback) {
                return new Call("getDataSet", [ ], callback);
            },
            
            /* Returns the Northwind employees as a DataTable. */
            
            "getDataTable" : function(callback) {
                return new Call("getDataTable", [ ], callback);
            },
            
            /* Returns the Northwind employees as a DataView object. */
            
            "getDataView" : function(callback) {
                return new Call("getDataView", [ ], callback);
            },
            
            /* Returns a data-bound DropDownList to the client as HTML. */
            
            "getDropDown" : function(callback) {
                return new Call("getDropDown", [ ], callback);
            },
            
            /* Returns the first Northwind employee as a DataRow object. */
            
            "getFirstDataRow" : function(callback) {
                return new Call("getFirstDataRow", [ ], callback);
            },
            
            /* Returns the first Northwind employee as a DataRowView object. */
            
            "getFirstDataRowView" : function(callback) {
                return new Call("getFirstDataRowView", [ ], callback);
            },
            
            /* Returns the Northwind employees as an array of DataRow objects. */
            
            "getRowArray" : function(callback) {
                return new Call("getRowArray", [ ], callback);
            },
            
            /* Returns the Northwind employees as a DataRowCollection. */
            
            "getRowCollection" : function(callback) {
                return new Call("getRowCollection", [ ], callback);
            },
            
            /* Returns an array of city names. Demonstrates returning a strongly-typed array. */
            
            "getStringArray" : function(callback) {
                return new Call("getStringArray", [ ], callback);
            },
            
            /* Generates and returns a GUID as a string. */
            
            "newGuid" : function(callback) {
                return new Call("newGuid", [ ], callback);
            },
            
            /* Returns the local time on the server. Demonstrates how DateTime is returned simply as a string using the ISO 8601 format. */
            
            "now" : function(callback) {
                return new Call("now", [ ], callback);
            },
            
            /* Returns the server variables collection at the server. Demonstrates returning NameValueCollection. */
            
            "serverVariables" : function(callback) {
                return new Call("serverVariables", [ ], callback);
            },
            
            /* Blocks the request for the specified number of milliseconds (maximum 7 seconds). */
            
            "sleep" : function(milliseconds, callback) {
                return new Call("sleep", [ milliseconds ], callback);
            },
            
            /* Returns the CLR type that a given value converted to on the server. */
            
            "stypeof" : function(o, callback) {
                return new Call("stypeof", [ o ], callback);
            },
            
            /* Swaps first and last name of person. Demonstrates receiving and returning a server-typed object. */
            
            "swapNames" : function(p, callback) {
                return new Call("swapNames", [ p ], callback);
            },
            
            /* Returns a summary about the server implementation for display purposes. */
            
            "system.about" : function(callback) {
                return new Call("system.about", [ ], callback);
            },
            
            /* Returns an array of method names implemented by this service. */
            
            "system.listMethods" : function(callback) {
                return new Call("system.listMethods", [ ], callback);
            },
            
            /* Returns the version server implementation using the major, minor, build and revision format. */
            
            "system.version" : function(callback) {
                return new Call("system.version", [ ], callback);
            },
            
            /* Throws an error if you try to call this method. */
            
            "throwError" : function(callback) {
                return new Call("throwError", [ ], callback);
            },
            
            /* Returns the total of all integers sent in an array. */
            
            "total" : function(values, callback) {
                return new Call("total", [ values ], callback);
            },
            
            /* Adds two float arguments and returns their result. This method demostrates use of warped parameters. */
            
            "wadd" : function(x, y, callback) {
                return new Call("wadd", [ x, y ], callback);
            }
        }
    }

    function Call(method, params, callback)
    {
        this.url = proxy.url;
        this.callback = callback;
        this.request = 
        { 
            id     : ++nextId, 
            method : method, 
            params : params
        };
    }
    
    Call.prototype.call = function(channel) { return channel(this); }
    
    return proxy;
}();
