using System.Xml;
using System.Xml.Schema;
using System.Text;
-#if !TARGET_JVM && !NET_2_1
+#if !NET_2_1
using System.CodeDom;
using System.CodeDom.Compiler;
using Microsoft.CSharp;
internal class SerializerData
{
public int UsageCount;
+ public bool Generated;
public Type ReaderType;
public MethodInfo ReaderMethod;
public Type WriterType;
// debugging pourposes by adding the "nofallback" option.
// For example: MONO_XMLSERIALIZER_THS=0,nofallback
-#if TARGET_JVM || NET_2_1
+#if NET_2_1
string db = null;
string th = null;
generationThreshold = -1;
#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
get { return typeMapping; }
}
-#if NET_2_0
[MonoTODO]
public XmlSerializer (Type type,
Evidence evidence)
{
}
-#endif
#endregion // Constructors
if (namespaces == null || namespaces.Count == 0) {
namespaces = new XmlSerializerNamespaces ();
-#if NET_2_0
namespaces.Add ("xsi", XmlSchema.InstanceNamespace);
namespaces.Add ("xsd", XmlSchema.Namespace);
-#else
- namespaces.Add ("xsd", XmlSchema.Namespace);
- namespaces.Add ("xsi", XmlSchema.InstanceNamespace);
-#endif
}
xsWriter.Initialize (xmlWriter, namespaces);
throw new NotImplementedException ();
}
-#if !TARGET_JVM && !MOBILE
+#if !MOBILE
public static Assembly GenerateSerializer (Type[] types, XmlMapping[] mappings)
{
return GenerateSerializer (types, mappings, null);
return new XmlSerializationReaderInterpreter (typeMapping);
}
-#if TARGET_JVM || NET_2_1
+#if NET_2_1
void CheckGeneratedTypes (XmlMapping typeMapping)
{
throw new NotImplementedException();
bool generate = false;
lock (serializerData)
{
- generate = (serializerData.UsageCount++ == generationThreshold);
+ if (serializerData.UsageCount >= generationThreshold && !serializerData.Generated)
+ serializerData.Generated = generate = true;
+
+ serializerData.UsageCount++;
}
if (generate)
cp.ReferencedAssemblies.Add ("System.Xml");
if (!cp.ReferencedAssemblies.Contains ("System.Data"))
cp.ReferencedAssemblies.Add ("System.Data");
+ if (!cp.ReferencedAssemblies.Contains ("System.Web.Services"))
+ cp.ReferencedAssemblies.Add ("System.Web.Services");
CompilerResults res = comp.CompileAssemblyFromFile (cp, file);
if (res.Errors.HasErrors || res.CompiledAssembly == null) {
}
#endif
-#if NET_2_0
GenerationBatch LoadFromSatelliteAssembly (GenerationBatch batch)
{
return batch;
}
-#else
- GenerationBatch LoadFromSatelliteAssembly (GenerationBatch batch)
- {
- return batch;
- }
-#endif
#endregion // Methods
}