当前位置: 首页>>代码示例>>C#>>正文


C# BinaryFormatter.DeserializeMethodResponse方法代码示例

本文整理汇总了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));
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:52,代码来源:SerializationTest.cs

示例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));
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:46,代码来源:SerializationTest.cs

示例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);
		}
开发者ID:nullie,项目名称:mono,代码行数:12,代码来源:CrossAppDomainChannel.cs

示例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; 
 }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:10,代码来源:RemotingServices.cs

示例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
		}
开发者ID:Profit0004,项目名称:mono,代码行数:16,代码来源:CrossAppDomainChannel.cs

示例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);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:9,代码来源:RemotingServices.cs

示例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;
     }
 }
开发者ID:curasystems,项目名称:externals,代码行数:20,代码来源:StackHeader.cs


注:本文中的System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.DeserializeMethodResponse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。