Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
SocketSerializer.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 #if !SILICONSTUDIO_PLATFORM_WINDOWS_RUNTIME
4 using System;
5 using System.Collections.Generic;
6 using System.Linq;
7 using System.Text;
8 using System.Runtime.Serialization.Formatters.Binary;
9 using System.IO;
10 
11 namespace SiliconStudio.Paradox.Engine.Network
12 {
13  // TODO: Switch to internal serialization engine
14  public class SocketSerializer
15  {
16  public Stream Stream { get; set; }
17  BinaryFormatter binaryFormatter = new BinaryFormatter();
18  public void Serialize(object obj)
19  {
20  if (Stream == null)
21  return;
22  lock (this)
23  {
24  binaryFormatter.Serialize(Stream, obj);
25  }
26  }
27  public object Deserialize()
28  {
29  return binaryFormatter.Deserialize(Stream);
30  }
31  }
32 }
33 #endif