The book of inspiration

February 10, 2008

C# To ActionScript, Initial LINQ Support

Filed under: jsc — Tags: , , , , , — zproxy @ 5:18 pm

I am introducing LINQ for ActionScript – you can now start writing your flash applications in c# using linq and convert it to actionscript via jsc compiler.

How does the generated code compare to the original

In c# the code looks like this:

foreach (var v in from i in __users

where i.Trim().ToLower().Contains(user_filter)

select i.Trim())

{

result.text += “result: “ + v + “\n”;

}

The generated ActionScript looks like this:

enumerator_15 = __Enumerable.Select_100663437(__Enumerable.Where_100663439(SZArrayEnumerator_1.op_Implicit_100664110(__users), new __Func_2(CS___8__locals15, __IntPtr.op_Explicit_100665307(“__ctor_b__8_100663306″))), FlashLinqToObjects___c__DisplayClassf.CS___9__CachedAnonymousMethodDelegate13).GetEnumerator_100664907();

try

{

while (enumerator_15.MoveNext_100665359())

{

v = enumerator_15.get_Current_100665499();

this.result.text = this.result.text+ “result: “+ v+ “\x0a”;

}

}

finally

{

if (!(enumerator_15 == null))

{

enumerator_15.Dispose_100665605();

}

}

New example project:



Download latest the jsc version here.

The Shocking Blue Green Theme Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 62 other followers