Esempio n. 1
0
        protected override T Deserialize(Stream stream)
        {
            _input.SetStream(stream);
            var result = _serializer.Deserialize(_input);

            _input.FinishRead();
            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// Populates a object fields with data from the stream
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="stream"></param>
        /// <param name="ob"></param>
        /// <param name="bufferSize"></param>
        /// <returns>false if type is not serializable</returns>
        public static bool TryPopulateObject <T>(Stream stream, ref T ob, int bufferSize = 4096 * 2)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            var serializerInput   = new SerializerInput(bufferSize, stream);
            var tryPopulateObject = _uSerializer.TryPopulateObject(serializerInput, ref ob);

            serializerInput.FinishRead();
            return(tryPopulateObject);
        }
Esempio n. 3
0
        /// <summary>
        /// Creates a object with data from the stream
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="stream"></param>
        /// <param name="result"></param>
        /// <param name="bufferSize"></param>
        /// <returns>false if type is not serializable</returns>
        public static bool TryDeserialize <T>(Stream stream, ref T result, int bufferSize = 4096 * 2)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            var serializerInput = new SerializerInput(bufferSize, stream);
            var tryDeserialize  = _uSerializer.TryDeserialize <T>(serializerInput, ref result);

            serializerInput.FinishRead();
            return(tryDeserialize);
        }