How to use this library - in typescript

You should add the .ts files under src to your typescript libary directory. For using this linq in typescript, you have to define the links to this files from within your typescript file. That could look like this:

/// <reference path="TsLinq.d.ts" />
/// <reference path="KeyValuePair.ts" />
/// <reference path="Dictionary.ts" />
/// <reference path="Linq.ts" />
/// <reference path="List.ts" />

Then you can use TsLinq. See the test files for more informations. Usage of Linq is very simple, for example, a linq object for list of numbers can be created like this:

stdLinq: Linq<number> = new Linq([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])

Then, for example, you can use it like the following:

this.stdLinq.cast<string>(item => item.toString())

Implementation behind that all is similar to C#. The current IEnumerable will never be changed when using linq methods. When you expect a list back, it returns a new IEnumerable of the specified type.

How to use this library - in html

In HTML you have to add all needed references to the produced javascript files:

    <script type="text/javascript" src="src/KeyValuePair.js"></script>
    <script type="text/javascript" src="src/DefaultComparer.js"></script>
    <script type="text/javascript" src="src/Linq.js"></script>
    <script type="text/javascript" src="src/List.js"></script>
    <script type="text/javascript" src="src/Dictionary.js"></script>

Then you can use the linq in javascript in your HTML page too. Look the tests.htm for a idea how to do that.

Last edited May 8, 2014 at 12:51 PM by mbaarz, version 1