CopyData() public method

public CopyData ( ) : byte[]
return byte[]
コード例 #1
0
 public byte[] Write <T>(T packet) where T : class, new()
 {
     _netDataWriter.Reset();
     WriteHash <T>(_netDataWriter);
     _netSerializer.Serialize(_netDataWriter, packet);
     return(_netDataWriter.CopyData());
 }
コード例 #2
0
        //public byte[] Write<T>(T packet) where T : class, new()
        //{
        //    _netDataWriter.Reset();
        //    WriteHash(typeof(T), _netDataWriter);
        //    _netSerializer.Serialize(_netDataWriter, packet);
        //    return _netDataWriter.CopyData();
        //}

        public byte[] WriteNetSerializable <T>(T packet) where T : INetSerializable
        {
            _netDataWriter.Reset();
            WriteHash(typeof(T), _netDataWriter);
            packet.Serialize(_netDataWriter);
            return(_netDataWriter.CopyData());
        }
コード例 #3
0
 /// <summary>
 /// Serialize object to byte array
 /// </summary>
 /// <param name="obj">Object to serialize</param>
 /// <returns>byte array with serialized data</returns>
 public byte[] Serialize <T>(T obj) where T : class, new()
 {
     if (_writer == null)
     {
         _writer = new NetDataWriter();
     }
     _writer.Reset();
     Serialize(_writer, obj);
     return(_writer.CopyData());
 }
コード例 #4
0
 /// <summary>
 /// Serialize struct to byte array
 /// </summary>
 /// <param name="obj">Struct to serialize</param>
 /// <returns>byte array with serialized data</returns>
 public byte[] Serialize <T>(T obj) where T : class, new()
 {
     _writer.Reset();
     Serialize(_writer, obj);
     return(_writer.CopyData());
 }
コード例 #5
0
 /// <summary>
 /// Serialize struct to byte array
 /// </summary>
 /// <param name="obj">Struct to serialize</param>
 /// <returns>byte array with serialized data</returns>
 public byte[] Serialize <T>(T obj) where T : struct
 {
     _writer.Reset();
     Serialize(_writer, obj);
     return(_writer.CopyData());
 }