Essentially it is all the magic late-binding stuff which VB does for you when you forget to go "Option Strict On". > RuntimeHelpers.GetObjectValue(x) just returns "x" boxed so you can omit it and the compiler puts it in for you. > NewLateBinding.LateIndexGet(instance, New Object() {"a"}, Nothing) as the name suggests is a late bound index get, such as: instance["a"] > NewLateBinding.LateGet(x, Nothing, "methodName", New Object() {"arg0", > "arg1"}, Nothing, Nothing, Nothing) is a function call, equivalent to x.methodName("arg0", "arg1")
The following is roughly equivalent source in VB (if you include the Try-Finally and GetEnumerator calls): For Each instance In someEnumerable eArrayList.Clear() eArrayList.AddRange(Strings.UCase("@@@ " & instance("e")).Split()) If ((Not sArrayList.Contains(instance("b")) And eArrayList.Contains(Strings.UCase(sGENRE))) And Not Module1.EdescList.Contains("SHOP")) Then Dim obj44 As Object = instance("b").replace("&", "and") sArrayList.Add(obj44) dArrayList.Add(instance("a")) uArrayList.Add(instance("a")) cArrayList.Add(instance("f").length.ToString) End If Next John P.S. I happen to recognise where the code is coming from, especially since you didn't quite completely sanitise it :p ---------------------------------------- > From: il.tho...@iinet.net.au > To: ozdotnet@ozdotnet.com > Subject: Decompilation - help unravelling syntax > Date: Mon, 20 Dec 2010 12:21:19 +0800 > > A Monday brain exercise: > > I have to reconstruct something (obtained by decompiling with Reflector > Pro), and would like some help unravelling some of the verbosity (VB.NET, > Framework 3.5 I think). > > Here's a sample (presented as best I can) - > > Do While enumerator.MoveNext > Dim instance As Object = RuntimeHelpers.GetObjectValue(enumerator.Current) > eArrayList.Clear() > > eArrayList.AddRange(DirectCast(NewLateBinding.LateGet(NewLateBinding.LateGet > (Nothing, GetType(Strings), "UCase", New Object() > {Operators.ConcatenateObject("@@@ ", NewLateBinding.LateIndexGet(instance, > New Object() {"e"}, Nothing))}, Nothing, Nothing, Nothing), Nothing, > "Split", New Object(0 - 1) {}, Nothing, Nothing, Nothing), ICollection)) > > If ((Not > sArrayList.Contains(RuntimeHelpers.GetObjectValue(NewLateBinding.LateIndexGe > t(instance, New Object() {"b"}, Nothing))) And > eArrayList.Contains(Strings.UCase(sGENRE))) And Not > Module1.EdescList.Contains("SHOP")) Then > Dim obj44 As Object = > RuntimeHelpers.GetObjectValue(NewLateBinding.LateGet(NewLateBinding.LateInde > xGet(instance, New Object() {"b"}, Nothing), Nothing, "replace", New > Object() {"&", "and"}, Nothing, Nothing, Nothing)) > sArrayList.Add(RuntimeHelpers.GetObjectValue(obj44)) > > dArrayList.Add(RuntimeHelpers.GetObjectValue(NewLateBinding.LateIndexGet(ins > tance, New Object() {"a"}, Nothing))) > > uArrayList.Add(RuntimeHelpers.GetObjectValue(NewLateBinding.LateIndexGet(ins > tance, New Object() {"a"}, Nothing))) > > cArrayList.Add(NewLateBinding.LateGet(NewLateBinding.LateIndexGet(instance, > New Object() {"f"}, Nothing), Nothing, "length", New Object(0 - 1) {}, > Nothing, Nothing, Nothing).ToString) > End If > Loop > > > Some variable types left out, but clear enough I think. > > As you might guess, it's a partial parsing of some JSON rendered to a > string. > > (Of course it will be easier to just rewrite the parsing, but I am > interested in the decompilation. I haven't looked at MSIL at all.) > ________________________________ > Ian Thomas > Victoria Park, Western Australia >