Start a new topic

Help converting JQuery TypeScript to C# DuoCode Bindings

I am creating jquery.d.cs file by hand using jquery.d.ts file:


I have encountered a couple items on the $.fn object


these items dont have name.


First items in my jQuery ($.fn) bindings:


    [Js(Name = "jQuery.fn", Extern = true, OptimizeArrayEnumeration = "toArray()")]

 public class JQueryResult : IEnumerable<Element>

 {

 /**

* Gets the JQuery library version ($.jquery)

*/

[Js(Name="jquery")] public extern string version { get; }


 /**

 * A selector representing selector passed to jQuery(), if any, when creating the original set.

 * version deprecated: 1.7, removed: 1.9

 */

public extern string selector { get; }


 /**

 * The number of elements in the jQuery object.

 */

public extern int length { get; }


//[index: string]: any;

 //[index: number]: HTMLElement;

}


What the heck are ([index: string]: any) and /[index: number]: HTMLElement) supposed to be, no name... is it a property or method or what... How whould i this a C# public extern


ALSO


What the heck is this supposed to be:


/**
* Interface for the JQuery promise/deferred callbacks
*/
interface JQueryPromiseCallback<T> {
(value?: T, ...args: any[]): void;
}

interface JQueryPromiseOperator<T, U> {
(callback1: JQueryPromiseCallback<T>|JQueryPromiseCallback<T>[], ...callbacksN: Array<JQueryPromiseCallback<any>|JQueryPromiseCallback<any>[]>): JQueryPromise<U>;
}


They are defined on the $.fn object but again no name but it looks like a method that returns a value... so how can it be a class with a constructor... is it a delegate? 


How to main C# of these couple of TypeScript definitions 

1 Comment

[index: string]: any; => public extern HTMLElement this[int index] { get; set; }


interface JQueryPromiseCallback<T> {
(value?: T, ...args: any[]): void;
}


Yes you right in TypeScript the above is a function/delegate, translated to C# like this:


public delegate void JQueryPromiseCallback<T>(value: T, params args: object[]); // currently it must be defined inside Js(Extern = true) class

Login or Signup to post a comment