/// <summary> /// Serializes a object fields to a stream /// </summary> /// <param name="obj"></param> /// <param name="stream"></param> /// <param name="bufferSize">buffer size used to copy to the stream</param> /// <returns>false if type is not serializable</returns> public static bool Serialize(object obj, Stream stream, int bufferSize = 4096 * 2) { if (obj == null) { throw new ArgumentNullException(nameof(obj)); } if (stream == null) { throw new ArgumentNullException(nameof(stream)); } var output = new SerializerOutput(bufferSize, stream); var serialize = _uSerializer.Serialize(output, obj); output.Flush(); return(serialize); }
protected override void Serialize(T obj, Stream stream) { _output.SetStream(stream); _serializer.Serialize(obj, _output); _output.Flush(); }