Files
Dec2017-Script-Dump/mscorlib/System/Runtime/Remoting/Channels/CADSerializer.cs
T
2026-06-04 11:42:34 +02:00

58 lines
1.7 KiB
C#

using System;
using System.IO;
using System.Runtime.Remoting.Messaging;
using System.Runtime.Serialization.Formatters.Binary;
namespace System.Runtime.Remoting.Channels
{
// Token: 0x0200039D RID: 925
internal class CADSerializer
{
// Token: 0x06002596 RID: 9622 RVA: 0x0007CC64 File Offset: 0x0007AE64
internal static IMessage DeserializeMessage(MemoryStream mem, IMethodCallMessage msg)
{
BinaryFormatter binaryFormatter = new BinaryFormatter();
binaryFormatter.SurrogateSelector = null;
mem.Position = 0L;
if (msg == null)
{
return (IMessage)binaryFormatter.Deserialize(mem, null);
}
return (IMessage)binaryFormatter.DeserializeMethodResponse(mem, null, msg);
}
// Token: 0x06002597 RID: 9623 RVA: 0x0007CCA8 File Offset: 0x0007AEA8
internal static MemoryStream SerializeMessage(IMessage msg)
{
MemoryStream memoryStream = new MemoryStream();
new BinaryFormatter
{
SurrogateSelector = new RemotingSurrogateSelector()
}.Serialize(memoryStream, msg);
memoryStream.Position = 0L;
return memoryStream;
}
// Token: 0x06002598 RID: 9624 RVA: 0x0007CCE0 File Offset: 0x0007AEE0
internal static MemoryStream SerializeObject(object obj)
{
MemoryStream memoryStream = new MemoryStream();
new BinaryFormatter
{
SurrogateSelector = new RemotingSurrogateSelector()
}.Serialize(memoryStream, obj);
memoryStream.Position = 0L;
return memoryStream;
}
// Token: 0x06002599 RID: 9625 RVA: 0x0007CD18 File Offset: 0x0007AF18
internal static object DeserializeObject(MemoryStream mem)
{
BinaryFormatter binaryFormatter = new BinaryFormatter();
binaryFormatter.SurrogateSelector = null;
mem.Position = 0L;
return binaryFormatter.Deserialize(mem);
}
}
}