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));
		}
		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));
		}
Exemplo n.º 3
0
		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);
		}
Exemplo n.º 4
0
 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; 
 }
Exemplo n.º 5
0
		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
		}
 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);
 }
Exemplo n.º 7
0
 /// <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;
     }
 }