Imported Upstream version 4.2.0.179

Former-commit-id: 0a113cb3a6feb7873f632839b1307cc6033cd595
This commit is contained in:
Xamarin Public Jenkins
2015-08-26 07:17:56 -04:00
committed by Jo Shields
parent 183bba2c9a
commit 6992685b86
7507 changed files with 90259 additions and 657307 deletions

View File

@@ -290,6 +290,7 @@ namespace System.Runtime.Remoting.Channels
{
internal static IMessage DeserializeMessage(MemoryStream mem, IMethodCallMessage msg)
{
#if FEATURE_REMOTING
BinaryFormatter serializer = new BinaryFormatter();
serializer.SurrogateSelector = null;
@@ -299,6 +300,9 @@ namespace System.Runtime.Remoting.Channels
return (IMessage) serializer.Deserialize(mem, null);
else
return (IMessage) serializer.DeserializeMethodResponse(mem, null, msg);
#else
throw new NotSupportedException ();
#endif
}
internal static MemoryStream SerializeMessage(IMessage msg)
@@ -314,6 +318,22 @@ namespace System.Runtime.Remoting.Channels
return mem;
}
// This wrapper deserializes the objects on
// it's input byte array. It's safe for concurrent use
// while Deserialize will modify the cursor of the MemoryStream
//
// It is also the preferred way to deserialize CADMessage
// objects because their payload must be stored as byte arrays to avoid
// cross-domain references to MemoryStream objects
internal static object DeserializeObjectSafe(byte[] mem)
{
byte [] outstream = new byte [mem.Length];
Array.Copy (mem, outstream, mem.Length);
MemoryStream objStream = new MemoryStream (outstream);
var returnVal = DeserializeObject (objStream);
return returnVal;
}
internal static MemoryStream SerializeObject(object obj)
{
MemoryStream mem = new MemoryStream ();