Represents options for stream on Packer/Unpacker creation.
Ejemplo n.º 1
0
 /// <summary>
 ///		 Creates the new <see cref="Unpacker"/> from specified stream.
 /// </summary>
 /// <param name="stream">The stream to be unpacked.</param>
 /// <param name="streamOptions"><see cref="PackerUnpackerStreamOptions"/> which specifies stream handling options.</param>
 /// <param name="unpackerOptions"><see cref="UnpackerOptions"/> which specifies various options. Specify <c>null</c> to use default options.</param>
 /// <returns><see cref="Unpacker"/> instance. This value will not be <c>null</c>.</returns>
 /// <exception cref="ArgumentNullException"><paramref name="stream"/> is <c>null</c>.</exception>
 public static Unpacker Create(Stream stream, PackerUnpackerStreamOptions streamOptions, UnpackerOptions unpackerOptions)
 {
     if (unpackerOptions == null || unpackerOptions.ValidationLevel == UnpackerValidationLevel.Collection)
     {
         return(new CollectionValidatingStreamUnpacker(stream, streamOptions));
     }
     else
     {
         return(new FastStreamUnpacker(stream, streamOptions));
     }
 }
        public MessagePackStreamUnpacker(Stream stream, PackerUnpackerStreamOptions streamOptions)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            var options = streamOptions ?? PackerUnpackerStreamOptions.None;

            this._source            = options.WrapStream(stream);
            this._ownsStream        = options.OwnsStream;
            this._useStreamPosition = stream.CanSeek;
            this._offset            = this._useStreamPosition ? stream.Position : 0L;
        }
Ejemplo n.º 3
0
        public MessagePackStreamPacker(Stream stream, PackerUnpackerStreamOptions streamOptions, PackerCompatibilityOptions compatibilityOptions)
            : base(compatibilityOptions)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            var options = streamOptions ?? PackerUnpackerStreamOptions.None;

            this._destination  = options.WrapStream(stream);
            this._ownsStream   = options.OwnsStream;
            this._scalarBuffer = new byte[sizeof(ulong) + 1];
        }
Ejemplo n.º 4
0
		public StreamPacker( Stream stream, PackerCompatibilityOptions compatibilityOptions, PackerUnpackerStreamOptions streamOptions )
			: base( compatibilityOptions )
		{
			if ( stream == null )
			{
				throw new ArgumentNullException( "stream" );
			}

			var options = streamOptions ?? PackerUnpackerStreamOptions.None;

			this._stream = options.WrapStream( stream );

			this._ownsStream = options.OwnsStream;
		}
Ejemplo n.º 5
0
 /// <summary>
 ///		Create standard Safe <see cref="Packer"/> instancde wrapping specified <see cref="Stream"/> with specified <see cref="PackerCompatibilityOptions"/>.
 /// </summary>
 /// <param name="stream"><see cref="Stream"/> object.</param>
 /// <param name="compatibilityOptions">A <see cref="PackerCompatibilityOptions"/> which specifies compatibility options.</param>
 /// <param name="streamOptions"><see cref="PackerUnpackerStreamOptions"/> which specifies stream handling options.</param>
 /// <returns>Safe <see cref="Packer"/>. This will not be null.</returns>
 /// <exception cref="ArgumentNullException"><paramref name="stream"/> is null.</exception>
 /// <remarks>
 ///		 You can specify any derived <see cref="Stream"/> class like FileStream, <see cref="MemoryStream"/>,
 ///		 NetworkStream, UnmanagedMemoryStream, or so.
 /// </remarks>
 public static Packer Create(Stream stream, PackerCompatibilityOptions compatibilityOptions, PackerUnpackerStreamOptions streamOptions)
 {
     return(new StreamPacker(stream, compatibilityOptions, streamOptions));
 }
Ejemplo n.º 6
0
 /// <summary>
 ///		 Creates the new <see cref="Unpacker"/> from specified stream.
 /// </summary>
 /// <param name="stream">The stream to be unpacked.</param>
 /// <param name="streamOptions"><see cref="PackerUnpackerStreamOptions"/> which specifies stream handling options.</param>
 /// <returns><see cref="Unpacker"/> instance.</returns>
 public static Unpacker Create(Stream stream, PackerUnpackerStreamOptions streamOptions)
 {
     return(new ItemsUnpacker(stream, streamOptions));
 }
Ejemplo n.º 7
0
 public CollectionValidatingStreamUnpacker(Stream stream, PackerUnpackerStreamOptions streamOptions)
     : base(stream, streamOptions)
 {
 }
Ejemplo n.º 8
0
 public FastStreamUnpacker(Stream stream, PackerUnpackerStreamOptions streamOptions)
     : base(stream, streamOptions)
 {
 }
Ejemplo n.º 9
0
 /// <summary>
 ///		 Creates the new <see cref="Unpacker"/> from specified stream.
 /// </summary>
 /// <param name="stream">The stream to be unpacked.</param>
 /// <param name="streamOptions"><see cref="PackerUnpackerStreamOptions"/> which specifies stream handling options.</param>
 /// <returns><see cref="Unpacker"/> instance. This value will not be <c>null</c>.</returns>
 /// <exception cref="ArgumentNullException"><paramref name="stream"/> is <c>null</c>.</exception>
 public static Unpacker Create(Stream stream, PackerUnpackerStreamOptions streamOptions)
 {
     return(Create(stream, streamOptions, null));
 }
Ejemplo n.º 10
0
		public ItemsUnpacker( Stream stream, PackerUnpackerStreamOptions streamOptions )
		{
			if ( stream == null )
			{
				throw new ArgumentNullException( "stream" );
			}

			var options = streamOptions ?? PackerUnpackerStreamOptions.None;
			this._source = options.WrapStream( stream );
			this._ownsStream = options.OwnsStream;
			this._useStreamPosition = stream.CanSeek;
			this._offset = this._useStreamPosition ? stream.Position : 0L;
		}
Ejemplo n.º 11
0
        public StreamPacker(Stream stream, PackerCompatibilityOptions compatibilityOptions, PackerUnpackerStreamOptions streamOptions)
            : base(compatibilityOptions)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            var options = streamOptions ?? PackerUnpackerStreamOptions.None;

            this._stream = options.WrapStream(stream);

            this._ownsStream = options.OwnsStream;
        }
Ejemplo n.º 12
0
		/// <summary>
		///		Create standard Safe <see cref="Packer"/> instancde wrapping specified <see cref="Stream"/> with specified <see cref="PackerCompatibilityOptions"/>.
		/// </summary>
		/// <param name="stream"><see cref="Stream"/> object.</param>
		/// <param name="compatibilityOptions">A <see cref="PackerCompatibilityOptions"/> which specifies compatibility options.</param>
		/// <param name="streamOptions"><see cref="PackerUnpackerStreamOptions"/> which specifies stream handling options.</param>
		/// <returns>Safe <see cref="Packer"/>. This will not be null.</returns>
		/// <exception cref="ArgumentNullException"><paramref name="stream"/> is null.</exception>
		/// <remarks>
		///		 You can specify any derived <see cref="Stream"/> class like FileStream, <see cref="MemoryStream"/>,
		///		 NetworkStream, UnmanagedMemoryStream, or so.
		/// </remarks>
		public static Packer Create( Stream stream, PackerCompatibilityOptions compatibilityOptions, PackerUnpackerStreamOptions streamOptions )
		{
			return new StreamPacker( stream, compatibilityOptions, streamOptions );
		}