//
// (C) 2002 Ximian, Inc. http://www.ximian.com
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
using System.Runtime.Serialization.Formatters;
using System.Runtime.Serialization;
using System.Reflection;
using System.Runtime.Remoting.Messaging;
namespace System.Runtime.Serialization.Formatters.Binary {
+
public sealed class BinaryFormatter : IRemotingFormatter, IFormatter
{
- private FormatterAssemblyStyle assembly_format; // TODO: Do something with this
+ private FormatterAssemblyStyle assembly_format = FormatterAssemblyStyle.Full;
private SerializationBinder binder;
private StreamingContext context;
private ISurrogateSelector surrogate_selector;
private FormatterTypeStyle type_format; // TODO: Do something with this
+#if NET_1_1
+ private TypeFilterLevel filter_level;
+#endif
+
public BinaryFormatter()
{
surrogate_selector=null;
}
}
+#if NET_1_1
+ [System.Runtime.InteropServices.ComVisible (false)]
+ public TypeFilterLevel FilterLevel
+ {
+ get { return filter_level; }
+ set { filter_level = value; }
+ }
+#endif
+
public object Deserialize(Stream serializationStream)
{
return Deserialize (serializationStream, null);
BinaryElement elem = (BinaryElement) reader.PeekChar();
if (elem == BinaryElement.MethodCall) {
- return MessageFormatter.ReadMethodCall (reader, hasHeader, handler, surrogate_selector, context, binder);
+ return MessageFormatter.ReadMethodCall (reader, hasHeader, handler, this);
}
else if (elem == BinaryElement.MethodResponse) {
- return MessageFormatter.ReadMethodResponse (reader, hasHeader, handler, null, surrogate_selector, context, binder);
+ return MessageFormatter.ReadMethodResponse (reader, hasHeader, handler, null, this);
}
else {
- ObjectReader serializer = new ObjectReader (surrogate_selector, context, binder);
+ ObjectReader serializer = new ObjectReader (this);
object result;
Header[] headers;
bool hasHeader;
ReadBinaryHeader (reader, out hasHeader);
- return MessageFormatter.ReadMethodResponse (reader, hasHeader, handler, methodCallmessage, surrogate_selector, context, binder);
+ return MessageFormatter.ReadMethodResponse (reader, hasHeader, handler, methodCallmessage, this);
}
public void Serialize(Stream serializationStream, object graph)
WriteBinaryHeader (writer, headers!=null);\r
\r
if (graph is IMethodCallMessage) {\r
- MessageFormatter.WriteMethodCall (writer, graph, headers, surrogate_selector, context);\r
+ MessageFormatter.WriteMethodCall (writer, graph, headers, surrogate_selector, context, assembly_format);\r
}\r
else if (graph is IMethodReturnMessage) {\r
- MessageFormatter.WriteMethodResponse (writer, graph, headers, surrogate_selector, context);\r
+ MessageFormatter.WriteMethodResponse (writer, graph, headers, surrogate_selector, context, assembly_format);\r
}\r
else {\r
- ObjectWriter serializer = new ObjectWriter (surrogate_selector, context);
+ ObjectWriter serializer = new ObjectWriter (surrogate_selector, context, assembly_format);
serializer.WriteObjectGraph (writer, graph, headers);
}
writer.Flush();
}
\r
+ [MonoTODO]
+ [System.Runtime.InteropServices.ComVisible (false)]
+ public object UnsafeDeserialize(Stream serializationStream, HeaderHandler handler)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ [System.Runtime.InteropServices.ComVisible (false)]
+ public object UnsafeDeserializeMethodResponse(Stream serializationStream, HeaderHandler handler, IMethodCallMessage methodCallmessage)
+ {
+ throw new NotImplementedException ();
+ }
+
private void WriteBinaryHeader (BinaryWriter writer, bool hasHeaders)\r
{\r
writer.Write ((byte)BinaryElement.Header);\r