Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>After searching for ages I still found nothing on auto generating these proxy classes for Ajax calls, so in the end I wrote a little script generating application that looks at a particular .Net library and then for each class in that library creates a Javascript representation of that class. So, for the object above, it generates the following javascript class:</p> <p>var MyLibEntities = new function () {</p> <pre><code>this.MyLibBase = function () { var t = this; }; this.MyLibBase.prototype.entityHashCode = null; this.MyLibBase.prototype.validate = function () { return ValidateObject(this); }; this.MyLibBase.prototype.getEntityName = function () { if (this.__type != null) { //split the __type param with : to get the Entity Name - 1st element var ary = this.__type.split(":"); if (ary.length &gt; 0) return ary[0] else return this.__type; } } this.MyLibBase.prototype.clone = function (source) { if (source !== undefined &amp;&amp; source !== null) { //if the source object is not of the same type we should not instantiate the object if (this.__type != source.__type) { var errormsg = "Object type '" + source.__type + "' does not match object type '" + this.__type + "'"; if (typeof console != "undefined") { console.log(errormsg); } throw new Error(errormsg); } for (var i in source) { if (typeof this[i] != "undefined") { this[i] = source[i]; } } } }; this.MyCompoundType = function (wo) { var t = this; t.__type = "MyCompoundType:#MyLib.Entities"; //assign all the properties from the referencing object this.clone(wo); }; this.MyCompoundType.prototype = new this.MylibBase(); this.MyCompoundType.prototype.constructor = this.MyCompoundType; this.MyCompoundType.prototype.IntegerVal = null; this.MyCompoundType.prototype.StringVal = null; this.MyCompoundType.prototype.DateVal = null; </code></pre> <p>}</p> <p>Whilst this is not exactly the same type, it gives me intellisense and I can pass this object to the MSAjax methods. It's constructor can receive an JSON object passed back from the WCF, which is then used in the clone function to assign the properties.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload