// Author:
// Lluis Sanchez Gual (lluis@ximian.com)
//
-// Copyright (C) 2003 Ximian, Inc.\r
+// Copyright (C) 2003 Ximian, Inc.
//
//
using System.Reflection;
using System.Collections;
-\r
-namespace System.Xml.Serialization\r
-{\r
- internal class ReflectionHelper\r
- {\r
+
+namespace System.Xml.Serialization
+{
+ internal class ReflectionHelper
+ {
Hashtable _clrTypes = new Hashtable ();
Hashtable _schemaTypes = new Hashtable ();
-\r
+
public void RegisterSchemaType (XmlTypeMapping map, string xmlType, string ns)
{
string mapKey = xmlType + "/" + ns;
if (type == typeof(object)) ns = "";
string mapKey = type.FullName + "/" + ns;
return _clrTypes[mapKey] as XmlTypeMapping;
- } \r
-\r
+ }
+
public Exception CreateError (XmlTypeMapping map, string message)
{
return new InvalidOperationException ("There was an error reflecting '" + map.TypeFullName + "': " + message);
}
-
+
+#if NET_2_0
+ static readonly ParameterModifier [] empty_modifiers = new ParameterModifier [0];
+#endif
+
public static void CheckSerializableType (Type type, bool allowPrivateConstructors)
{
if (type.IsArray) return;
+#if NET_2_0
+ if (!allowPrivateConstructors && type.GetConstructor (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null, Type.EmptyTypes, empty_modifiers) == null && !type.IsAbstract && !type.IsValueType)
+#else
if (!allowPrivateConstructors && type.GetConstructor (Type.EmptyTypes) == null && !type.IsAbstract && !type.IsValueType)
+#endif
throw new InvalidOperationException (type.FullName + " cannot be serialized because it does not have a default public constructor");
if (type.IsInterface && !TypeTranslator.GetTypeData (type).IsListType)
return res;
}
- }\r
+ }
}