本文整理汇总了C#中System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.DeserializeMethodResponse方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryFormatter.DeserializeMethodResponse方法的具体用法?C# BinaryFormatter.DeserializeMethodResponse怎么用?C# BinaryFormatter.DeserializeMethodResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
的用法示例。
在下文中一共展示了BinaryFormatter.DeserializeMethodResponse方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadData
void ReadData()
{
StreamingContext context = new StreamingContext (StreamingContextStates.Other);
SurrogateSelector sel = new SurrogateSelector();
sel.AddSurrogate (typeof (Point), context, new PointSurrogate());
sel.AddSurrogate (typeof (FalseISerializable), context, new FalseISerializableSurrogate());
BinaryFormatter f = new BinaryFormatter (sel, context);
object list = f.Deserialize (ms);
object[][] originalMsgData = null;
IMessage[] calls = null;
IMessage[] resps = null;
originalMsgData = ProcessMessages (null, null);
calls = new IMessage[originalMsgData.Length];
resps = new IMessage[originalMsgData.Length];
for (int n=0; n<originalMsgData.Length; n++)
{
calls[n] = (IMessage) f.Deserialize (ms);
resps[n] = (IMessage) f.DeserializeMethodResponse (ms, null, (IMethodCallMessage)calls[n]);
}
f.Binder = new TestBinder ();
object btbob = f.Deserialize (ms);
ms.Close();
List expected = CreateTestData ();
List actual = (List) list;
expected.CheckEquals (actual, "List");
for (int i = 0; i < actual.children.Length - 1; ++i)
if (actual.children [i].next != actual.children [i+1])
Assert.Fail ("Deserialization did not restore pointer graph");
BinderTester_A bta = CreateBinderTestData();
Assert.AreEqual (btbob.GetType(), typeof (BinderTester_B), "BinderTest.class");
BinderTester_B btb = btbob as BinderTester_B;
if (btb != null)
{
Assert.AreEqual (btb.x, bta.x, "BinderTest.x");
Assert.AreEqual (btb.y, bta.y, "BinderTest.y");
}
CheckMessages ("MethodCall", originalMsgData, ProcessMessages (null, calls));
CheckMessages ("MethodResponse", originalMsgData, ProcessMessages (null, resps));
}
示例2: ReadData
void ReadData()
{
StreamingContext context = new StreamingContext (StreamingContextStates.Other);
SurrogateSelector sel = new SurrogateSelector();
sel.AddSurrogate (typeof (Point), context, new PointSurrogate());
sel.AddSurrogate (typeof (FalseISerializable), context, new FalseISerializableSurrogate());
BinaryFormatter f = new BinaryFormatter (sel, context);
object list = f.Deserialize (ms);
object[][] originalMsgData = null;
IMessage[] calls = null;
IMessage[] resps = null;
originalMsgData = ProcessMessages (null, null);
calls = new IMessage[originalMsgData.Length];
resps = new IMessage[originalMsgData.Length];
for (int n=0; n<originalMsgData.Length; n++)
{
calls[n] = (IMessage) f.Deserialize (ms);
resps[n] = (IMessage) f.DeserializeMethodResponse (ms, null, (IMethodCallMessage)calls[n]);
}
f.Binder = new TestBinder ();
object btbob = f.Deserialize (ms);
ms.Close();
((List)list).CheckEquals(CreateTestData());
BinderTester_A bta = CreateBinderTestData();
Assertion.AssertEquals ("BinderTest.class", btbob.GetType(), typeof (BinderTester_B));
BinderTester_B btb = btbob as BinderTester_B;
if (btb != null)
{
Assertion.AssertEquals ("BinderTest.x", btb.x, bta.x);
Assertion.AssertEquals ("BinderTest.y", btb.y, bta.y);
}
CheckMessages ("MethodCall", originalMsgData, ProcessMessages (null, calls));
CheckMessages ("MethodResponse", originalMsgData, ProcessMessages (null, resps));
}
示例3: DeserializeMessage
internal static IMessage DeserializeMessage(MemoryStream mem, IMethodCallMessage msg)
{
BinaryFormatter serializer = new BinaryFormatter();
serializer.SurrogateSelector = null;
mem.Position = 0;
if (msg == null)
return (IMessage) serializer.Deserialize(mem, null);
else
return (IMessage) serializer.DeserializeMethodResponse(mem, null, msg);
}
示例4: UnmarshalReturnMessageFromBuffer
internal static Object UnmarshalReturnMessageFromBuffer(byte [] b, IMethodCallMessage msg)
{
MemoryStream stm = new MemoryStream(b);
BinaryFormatter fmt = new BinaryFormatter();
fmt.SurrogateSelector = null;
fmt.Context = new StreamingContext(StreamingContextStates.Other);
Object o = fmt.DeserializeMethodResponse(stm, null, (IMethodCallMessage)msg);
//= fmt.Deserialize(stm, null, false /* No Security check */);
return o;
}
示例5: DeserializeMessage
internal static IMessage DeserializeMessage(MemoryStream mem, IMethodCallMessage msg)
{
#if FEATURE_REMOTING
BinaryFormatter serializer = new BinaryFormatter();
serializer.SurrogateSelector = null;
mem.Position = 0;
if (msg == null)
return (IMessage) serializer.Deserialize(mem, null);
else
return (IMessage) serializer.DeserializeMethodResponse(mem, null, msg);
#else
throw new NotSupportedException ();
#endif
}
示例6: UnmarshalReturnMessageFromBuffer
internal static object UnmarshalReturnMessageFromBuffer(byte[] b, IMethodCallMessage msg)
{
MemoryStream serializationStream = new MemoryStream(b);
BinaryFormatter formatter = new BinaryFormatter {
SurrogateSelector = null,
Context = new StreamingContext(StreamingContextStates.Other)
};
return formatter.DeserializeMethodResponse(serializationStream, null, msg);
}
示例7: deserializeResponse
/// <remarks>
/// This is performed seperately as the initial message request is needed
/// to deserialize the response properly.
/// </remarks>
/// <summary>
/// Deserialises the request message.
/// </summary>
/// <param name="reqMsg"></param>
public void deserializeResponse(IMethodCallMessage reqMsg)
{
if(stream != null)
{
BinaryFormatter fmt = new BinaryFormatter();
fmt.AssemblyFormat = FormatterAssemblyStyle.Full;
stream.Position = 0;
IMessage replyMsg = (IMessage)fmt.DeserializeMethodResponse(stream, null, reqMsg);
msg = replyMsg;
stream = null;
}
}