import System.Diagnostics.Trace etc. from referencesource.
[mono.git] / mcs / class / System.XML / System.Xml.Serialization / XmlSerializer.cs
index 8e9fe3e91bf86055ebf2019c66f76db07e94f97d..35d149a4ebefdd20b7f784e97c7a1e9254aad009 100644 (file)
@@ -151,14 +151,21 @@ namespace System.Xml.Serialization
 #endif
                        deleteTempFiles = (db == null || db == "no");
 #if !NET_2_1
-                       IDictionary table = (IDictionary) ConfigurationSettings.GetConfig("system.diagnostics");
+                       // DiagnosticsSection
+                       ConfigurationSection table = (ConfigurationSection) ConfigurationSettings.GetConfig("system.diagnostics");
+                       var bf = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
                        if (table != null) 
                        {
-                               table = (IDictionary) table["switches"];
-                               if (table != null) 
-                               {
-                                       string val = (string) table ["XmlSerialization.Compilation"];
-                                       if (val == "1") deleteTempFiles = false;
+                               // SwitchElementsCollection
+                               var pi = table.GetType ().GetProperty ("Switches", bf);
+                               var switchesElement = (ConfigurationElementCollection) pi.GetValue (table, null);
+                               foreach (ConfigurationElement e in switchesElement) {
+                                       // SwitchElement
+                                       if (e.GetType ().GetProperty ("Name", bf).GetValue (e, null) as string == "XmlSerialization.Compilation") {
+                                               if (e.GetType ().GetProperty ("Value", bf).GetValue (e, null) as string == "1")
+                                                       deleteTempFiles = false;
+                                               break;
+                                       }
                                }
                        }
 #endif