Patches for Silverlight build

Jul 30, 2012 at 6:50 AM

--- fastJSON-SL.csproj    Sat Sep 19 07:12:56 1970
+++ fastJSON-SL.csproj    Sat Sep 19 07:12:56 1970
@@ -55,10 +56,12 @@
     <Reference Include="System.Windows.Browser" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="Formatter.cs" />
     <Compile Include="Getters.cs" />
     <Compile Include="JSON.cs" />
     <Compile Include="JsonParser.cs" />
     <Compile Include="JsonSerializer.cs" />
+    <Compile Include="Reflection.cs" />
     <Compile Include="SafeDictionary.cs" />
   </ItemGroup>
   <ItemGroup>
--- JSON.cs    Sat Sep 19 09:00:40 1970
+++ JSON.cs    Sat Sep 19 09:00:40 1970
@@ -525,7 +525,7 @@
             {
                 object ob = data[i];
                 if (ob is IDictionary)
-                    col.SetValue(ParseDictionary((Dictionary<string, object>)ob, globalTypes, bt), i);
+                    col.SetValue(ParseDictionary((Dictionary<string, object>)ob, globalTypes, bt, null), i);
                 else
                     col.SetValue(ChangeType(ob, bt), i);
             }
--- Reflection.cs    Sat Sep 19 07:12:56 1970
+++ Reflection.cs    Sat Sep 19 07:12:56 1970
@@ -4,7 +4,6 @@
 using System.Reflection.Emit;
 using System.Reflection;
 using System.Collections;
-using System.Data;
 
 namespace fastJSON
 {
@@ -70,12 +69,17 @@
                 }
                 else
                 {
+#if SILVERLIGHT
+                    DynamicMethod dynMethod = new DynamicMethod("_",
+                        typeof(object), null);
+#else
                     DynamicMethod dynMethod = new DynamicMethod("_",
                         MethodAttributes.Public | MethodAttributes.Static,
                         CallingConventions.Standard,
                         typeof(object),
                         null,
                         objtype, false);
+#endif
                     ILGenerator ilGen = dynMethod.GetILGenerator();
 
                     if (objtype.IsClass)
@@ -110,8 +114,11 @@
         {
             Type[] arguments = new Type[2];
             arguments[0] = arguments[1] = typeof(object);
-
+#if SILVERLIGHT
+            DynamicMethod dynamicSet = new DynamicMethod("_", typeof(object), arguments);
+#else
             DynamicMethod dynamicSet = new DynamicMethod("_", typeof(object), arguments, type, true);
+#endif
             ILGenerator il = dynamicSet.GetILGenerator();
 
             if (!type.IsClass) // structs
@@ -152,8 +159,12 @@
 
             Type[] arguments = new Type[2];
             arguments[0] = arguments[1] = typeof(object);
-
+#if SILVERLIGHT
+            DynamicMethod setter = new DynamicMethod("_", typeof(object), arguments);
+#else
             DynamicMethod setter = new DynamicMethod("_", typeof(object), arguments, type);
+#endif
+
             ILGenerator il = setter.GetILGenerator();
 
             if (!type.IsClass) // structs
@@ -192,7 +203,11 @@
 
         internal static GenericGetter CreateGetField(Type type, FieldInfo fieldInfo)
         {
+#if SILVERLIGHT
+            DynamicMethod dynamicGet = new DynamicMethod("_", typeof(object), new Type[] { typeof(object) });
+#else
             DynamicMethod dynamicGet = new DynamicMethod("_", typeof(object), new Type[] { typeof(object) }, type, true);
+#endif
             ILGenerator il = dynamicGet.GetILGenerator();
 
             if (!type.IsClass) // structs
@@ -227,8 +242,11 @@
 
             Type[] arguments = new Type[1];
             arguments[0] = typeof(object);
-
+#if SILVERLIGHT
+            DynamicMethod getter = new DynamicMethod("_", typeof(object), arguments);
+#else
             DynamicMethod getter = new DynamicMethod("_", typeof(object), arguments, type);
+#endif
             ILGenerator il = getter.GetILGenerator();
            
             if (!type.IsClass) // structs