public byte[] Write <T>(T packet) where T : class, new() { _netDataWriter.Reset(); WriteHash <T>(_netDataWriter); _netSerializer.Serialize(_netDataWriter, packet); return(_netDataWriter.CopyData()); }
//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()); }
/// <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()); }
/// <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()); }
/// <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()); }