2005-01-31 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / class / corlib / System.Runtime.Serialization.Formatters.Binary / BinaryCommon.cs
index 53f96a06eff807ac3edb4cfd664195a82c6cdf08..3adc40b70b9f5b29de1ddb6ef541fa1f8fd93c86 100644 (file)
@@ -91,7 +91,7 @@ namespace System.Runtime.Serialization.Formatters.Binary
 \r
                public static bool IsPrimitive (Type type)\r
                {\r
-                       return type.IsPrimitive || \r
+                       return (type.IsPrimitive && type != typeof (IntPtr)) || \r
                                type == typeof (DateTime) || \r
                                type == typeof (TimeSpan) || \r
                                type == typeof (Decimal);\r
@@ -107,6 +107,17 @@ namespace System.Runtime.Serialization.Formatters.Binary
                {\r
                        return _typeCodesToType [code];\r
                }\r
+               \r
+               public static void CheckSerializable (Type type, ISurrogateSelector selector, StreamingContext context)\r
+               {\r
+                       if (!type.IsSerializable && !type.IsInterface) \r
+                       {\r
+                               if (selector != null && selector.GetSurrogate (type, context, out selector) != null)\r
+                                       return;\r
+\r
+                               throw new SerializationException ("Type " + type + " is not marked as Serializable.");\r
+                       }\r
+               }\r
        }\r
 \r
        internal enum BinaryElement : byte\r