C# Class MsgPack.Packer

Implements serialization feature of MsgPack.
Inheritance: IDisposable
显示文件 Open project: msgpack/msgpack-cli Class Usage Examples

Public Methods

Method Description
Create ( Stream stream ) : Packer

Create standard Safe Packer instancde wrapping specified Stream with DefaultCompatibilityOptions.

You can specify any derived Stream class like FileStream, MemoryStream, NetworkStream, UnmanagedMemoryStream, or so.

Create ( Stream stream, PackerCompatibilityOptions compatibilityOptions ) : Packer

Create standard Safe Packer instancde wrapping specified Stream with specified PackerCompatibilityOptions.

You can specify any derived Stream class like FileStream, MemoryStream, NetworkStream, UnmanagedMemoryStream, or so.

Create ( Stream stream, PackerCompatibilityOptions compatibilityOptions, PackerUnpackerStreamOptions streamOptions ) : Packer

Create standard Safe Packer instancde wrapping specified Stream with specified PackerCompatibilityOptions.

You can specify any derived Stream class like FileStream, MemoryStream, NetworkStream, UnmanagedMemoryStream, or so.

Create ( Stream stream, PackerCompatibilityOptions compatibilityOptions, bool ownsStream ) : Packer

Create standard Safe Packer instancde wrapping specified Stream with specified PackerCompatibilityOptions.

You can specify any derived Stream class like FileStream, MemoryStream, NetworkStream, UnmanagedMemoryStream, or so.

Create ( Stream stream, bool ownsStream ) : Packer

Create standard Safe Packer instancde wrapping specified Stream with DefaultCompatibilityOptions.

You can specify any derived Stream class like FileStream, MemoryStream, NetworkStream, UnmanagedMemoryStream, or so.

Dispose ( ) : void

Clean up internal resources.

Flush ( ) : void

Flushes internal buffer (including underlying stream).

FlushAsync ( ) : Task

Flushes internal buffer (including underlying stream) asynchronously.

FlushAsync ( CancellationToken cancellationToken ) : Task

Flushes internal buffer (including underlying stream) asynchronously.

Pack ( System.Boolean value ) : Packer

Pack nullable Boolean value.

Pack ( Byte value ) : Packer

Pack nullable Byte value.

Pack ( Double value ) : Packer

Pack nullable Double value.

Pack ( Int16 value ) : Packer

Pack nullable Int16 value.

Pack ( Int32 value ) : Packer

Pack nullable Int32 value.

Pack ( System.Int64 value ) : Packer

Pack nullable Int64 value.

Pack ( System.Single value ) : Packer

Pack nullable Single value.

Pack ( bool value ) : Packer

Packs Boolean value to current stream.

Pack ( byte value ) : Packer

Packs Byte value to current stream.

PackAsync ( System.Boolean value ) : Task

Pack nullable Boolean value asynchronously.

PackAsync ( System.Boolean value, CancellationToken cancellationToken ) : Task

Pack nullable Boolean value asynchronously.

PackAsync ( Byte value ) : Task

Pack nullable Byte value asynchronously.

PackAsync ( Byte value, CancellationToken cancellationToken ) : Task

Pack nullable Byte value asynchronously.

PackAsync ( Double value ) : Task

Pack nullable Double value asynchronously.

PackAsync ( Double value, CancellationToken cancellationToken ) : Task

Pack nullable Double value asynchronously.

PackAsync ( Int16 value ) : Task

Pack nullable Int16 value asynchronously.

PackAsync ( Int16 value, CancellationToken cancellationToken ) : Task

Pack nullable Int16 value asynchronously.

PackAsync ( Int32 value ) : Task

Pack nullable Int32 value asynchronously.

PackAsync ( Int32 value, CancellationToken cancellationToken ) : Task

Pack nullable Int32 value asynchronously.

PackAsync ( System.Int64 value ) : Task

Pack nullable Int64 value asynchronously.

PackAsync ( System.Int64 value, CancellationToken cancellationToken ) : Task

Pack nullable Int64 value asynchronously.

PackAsync ( System.Single value ) : Task

Pack nullable Single value asynchronously.

PackAsync ( System.Single value, CancellationToken cancellationToken ) : Task

Pack nullable Single value asynchronously.

PackAsync ( bool value ) : Task

Packs Boolean value to current stream asynchronously.

PackAsync ( bool value, CancellationToken cancellationToken ) : Task

Packs Boolean value to current stream asynchronously.

PackAsync ( byte value ) : Task

Packs Byte value to current stream asynchronously.

PackAsync ( byte value, CancellationToken cancellationToken ) : Task

Packs Byte value to current stream asynchronously.

PackNull ( ) : Packer

Packs a null value to current stream.

PackNullAsync ( ) : Task

Packs a null value to current stream asynchronously.

PackNullAsync ( CancellationToken cancellationToken ) : Task

Packs a null value to current stream asynchronously.

Protected Methods

Method Description
Dispose ( bool disposing ) : void

When overridden by derived class, release all unmanaged resources, optionally release managed resources.

Packer ( ) : System

Initializes a new instance of the Packer class with DefaultCompatibilityOptions.

Packer ( PackerCompatibilityOptions compatibilityOptions ) : System

Initializes a new instance of the Packer class with specified PackerCompatibilityOptions.

SeekTo ( long offset ) : void

When overridden by derived class, change current position to specified offset.

TryPackInt8 ( long value ) : bool

Try packs SByte value to current stream strictly.

TryPackInt8Async ( long value ) : Task

Try packs SByte value to current stream strictly asynchronously.

TryPackInt8Async ( long value, CancellationToken cancellationToken ) : Task

Try packs SByte value to current stream strictly asynchronously.

TryPackTinySignedInteger ( long value ) : bool

Try packs SByte value to current stream as tiny fix num.

TryPackTinySignedIntegerAsync ( long value ) : Task

Try packs SByte value to current stream as tiny fix num asynchronously.

TryPackTinySignedIntegerAsync ( long value, CancellationToken cancellationToken ) : Task

Try packs SByte value to current stream as tiny fix num asynchronously.

WriteByte ( byte value ) : void

When overridden by derived class, writes specified byte to stream using implementation specific manner.

WriteByteAsync ( byte value ) : Task

When overridden by derived class, writes specified byte to stream using implementation specific manner asynchronously.

WriteByteAsync ( byte value, CancellationToken cancellationToken ) : Task

When overridden by derived class, writes specified byte to stream using implementation specific manner asynchronously.

WriteBytesAsync ( ICollection value ) : Task

Writes specified bytes to stream using implementation specific most efficient manner asynchronously.

WriteBytesAsync ( ICollection value, CancellationToken cancellationToken ) : Task

Writes specified bytes to stream using implementation specific most efficient manner asynchronously.

WriteBytesAsync ( byte value, bool isImmutable ) : Task

Writes specified bytes to stream using implementation specific most efficient manner asynchronously.

WriteBytesAsync ( byte value, bool isImmutable, CancellationToken cancellationToken ) : Task

Writes specified bytes to stream using implementation specific most efficient manner asynchronously.

Private Methods

Method Description
Pack ( SByte value ) : Packer
Pack ( UInt16 value ) : Packer
Pack ( UInt32 value ) : Packer
Pack ( System.UInt64 value ) : Packer
Pack ( sbyte value ) : Packer
PackAsync ( SByte value ) : Task
PackAsync ( SByte value, CancellationToken cancellationToken ) : Task
PackAsync ( UInt16 value ) : Task
PackAsync ( UInt16 value, CancellationToken cancellationToken ) : Task
PackAsync ( UInt32 value ) : Task
PackAsync ( UInt32 value, CancellationToken cancellationToken ) : Task
PackAsync ( System.UInt64 value ) : Task
PackAsync ( System.UInt64 value, CancellationToken cancellationToken ) : Task
PackAsync ( sbyte value ) : Task
PackAsync ( sbyte value, CancellationToken cancellationToken ) : Task
PrivatePackAsyncCore ( bool value, CancellationToken cancellationToken ) : Task
PrivatePackAsyncCore ( byte value, CancellationToken cancellationToken ) : Task
PrivatePackAsyncCore ( sbyte value, CancellationToken cancellationToken ) : Task
PrivatePackCore ( bool value ) : void
PrivatePackCore ( byte value ) : void
PrivatePackCore ( sbyte value ) : void
PrivatePackNullAsyncCore ( CancellationToken cancellationToken ) : Task
PrivatePackNullCore ( ) : void
ThrowArgumentNullException ( string parameterName ) : void
ThrowCannotBeNegativeException ( string parameterName ) : void
ThrowExtTypeIsProhibitedException ( ) : void
ThrowMissingBodyOfExtTypeValueException ( string parameterName ) : void
ThrowObjectDisposedException ( ) : void
TryPackTinyUnsignedInteger ( ulong value ) : bool
TryPackTinyUnsignedIntegerAsync ( ulong value ) : Task
TryPackTinyUnsignedIntegerAsync ( ulong value, CancellationToken cancellationToken ) : Task
TryPackUInt8 ( ulong value ) : bool
TryPackUInt8Async ( ulong value ) : Task
TryPackUInt8Async ( ulong value, CancellationToken cancellationToken ) : Task
VerifyNotDisposed ( ) : void
WriteBytes ( ICollection value ) : void
WriteBytes ( byte value, bool isImmutable ) : void

Method Details

Create() public static method

Create standard Safe Packer instancde wrapping specified Stream with DefaultCompatibilityOptions.
You can specify any derived Stream class like FileStream, MemoryStream, NetworkStream, UnmanagedMemoryStream, or so.
is null.
public static Create ( Stream stream ) : Packer
stream Stream object. This stream will be closed when is called.
return Packer

Create() public static method

Create standard Safe Packer instancde wrapping specified Stream with specified PackerCompatibilityOptions.
You can specify any derived Stream class like FileStream, MemoryStream, NetworkStream, UnmanagedMemoryStream, or so.
is null.
public static Create ( Stream stream, PackerCompatibilityOptions compatibilityOptions ) : Packer
stream Stream object. This stream will be closed when is called.
compatibilityOptions PackerCompatibilityOptions A which specifies compatibility options.
return Packer

Create() public static method

Create standard Safe Packer instancde wrapping specified Stream with specified PackerCompatibilityOptions.
You can specify any derived Stream class like FileStream, MemoryStream, NetworkStream, UnmanagedMemoryStream, or so.
is null.
public static Create ( Stream stream, PackerCompatibilityOptions compatibilityOptions, PackerUnpackerStreamOptions streamOptions ) : Packer
stream Stream object.
compatibilityOptions PackerCompatibilityOptions A which specifies compatibility options.
streamOptions PackerUnpackerStreamOptions which specifies stream handling options.
return Packer

Create() public static method

Create standard Safe Packer instancde wrapping specified Stream with specified PackerCompatibilityOptions.
You can specify any derived Stream class like FileStream, MemoryStream, NetworkStream, UnmanagedMemoryStream, or so.
is null.
public static Create ( Stream stream, PackerCompatibilityOptions compatibilityOptions, bool ownsStream ) : Packer
stream Stream object.
compatibilityOptions PackerCompatibilityOptions A which specifies compatibility options.
ownsStream bool /// true to close when this instance is disposed; /// false, otherwise. ///
return Packer

Create() public static method

Create standard Safe Packer instancde wrapping specified Stream with DefaultCompatibilityOptions.
You can specify any derived Stream class like FileStream, MemoryStream, NetworkStream, UnmanagedMemoryStream, or so.
is null.
public static Create ( Stream stream, bool ownsStream ) : Packer
stream Stream object.
ownsStream bool /// true to close when this instance is disposed; /// false, otherwise. ///
return Packer

Dispose() public method

Clean up internal resources.
public Dispose ( ) : void
return void

Dispose() protected method

When overridden by derived class, release all unmanaged resources, optionally release managed resources.
protected Dispose ( bool disposing ) : void
disposing bool If true, release managed resources too.
return void

Flush() public method

Flushes internal buffer (including underlying stream).
public Flush ( ) : void
return void

FlushAsync() public method

Flushes internal buffer (including underlying stream) asynchronously.
public FlushAsync ( ) : Task
return Task

FlushAsync() public method

Flushes internal buffer (including underlying stream) asynchronously.
public FlushAsync ( CancellationToken cancellationToken ) : Task
cancellationToken System.Threading.CancellationToken The token to monitor for cancellation requests. The default value is .
return Task

Pack() public method

Pack nullable Boolean value.
public Pack ( System.Boolean value ) : Packer
value System.Boolean Value to serialize.
return Packer

Pack() public method

Pack nullable Byte value.
public Pack ( Byte value ) : Packer
value Byte Value to serialize.
return Packer

Pack() public method

Pack nullable Double value.
public Pack ( Double value ) : Packer
value Double Value to serialize.
return Packer

Pack() public method

Pack nullable Int16 value.
public Pack ( Int16 value ) : Packer
value System.Int16 Value to serialize.
return Packer

Pack() public method

Pack nullable Int32 value.
public Pack ( Int32 value ) : Packer
value System.Int32 Value to serialize.
return Packer

Pack() public method

Pack nullable Int64 value.
public Pack ( System.Int64 value ) : Packer
value System.Int64 Value to serialize.
return Packer

Pack() public method

Pack nullable Single value.
public Pack ( System.Single value ) : Packer
value System.Single Value to serialize.
return Packer

Pack() public method

Packs Boolean value to current stream.
public Pack ( bool value ) : Packer
value bool value.
return Packer

Pack() public method

Packs Byte value to current stream.
This instance has been disposed.
public Pack ( byte value ) : Packer
value byte value.
return Packer

PackAsync() public method

Pack nullable Boolean value asynchronously.
public PackAsync ( System.Boolean value ) : Task
value System.Boolean Value to serialize.
return Task

PackAsync() public method

Pack nullable Boolean value asynchronously.
public PackAsync ( System.Boolean value, CancellationToken cancellationToken ) : Task
value System.Boolean Value to serialize.
cancellationToken System.Threading.CancellationToken The token to monitor for cancellation requests. The default value is .
return Task

PackAsync() public method

Pack nullable Byte value asynchronously.
public PackAsync ( Byte value ) : Task
value Byte Value to serialize.
return Task

PackAsync() public method

Pack nullable Byte value asynchronously.
public PackAsync ( Byte value, CancellationToken cancellationToken ) : Task
value Byte Value to serialize.
cancellationToken System.Threading.CancellationToken The token to monitor for cancellation requests. The default value is .
return Task

PackAsync() public method

Pack nullable Double value asynchronously.
public PackAsync ( Double value ) : Task
value Double Value to serialize.
return Task

PackAsync() public method

Pack nullable Double value asynchronously.
public PackAsync ( Double value, CancellationToken cancellationToken ) : Task
value Double Value to serialize.
cancellationToken System.Threading.CancellationToken The token to monitor for cancellation requests. The default value is .
return Task

PackAsync() public method

Pack nullable Int16 value asynchronously.
public PackAsync ( Int16 value ) : Task
value System.Int16 Value to serialize.
return Task

PackAsync() public method

Pack nullable Int16 value asynchronously.
public PackAsync ( Int16 value, CancellationToken cancellationToken ) : Task
value System.Int16 Value to serialize.
cancellationToken System.Threading.CancellationToken The token to monitor for cancellation requests. The default value is .
return Task

PackAsync() public method

Pack nullable Int32 value asynchronously.
public PackAsync ( Int32 value ) : Task
value System.Int32 Value to serialize.
return Task

PackAsync() public method

Pack nullable Int32 value asynchronously.
public PackAsync ( Int32 value, CancellationToken cancellationToken ) : Task
value System.Int32 Value to serialize.
cancellationToken System.Threading.CancellationToken The token to monitor for cancellation requests. The default value is .
return Task

PackAsync() public method

Pack nullable Int64 value asynchronously.
public PackAsync ( System.Int64 value ) : Task
value System.Int64 Value to serialize.
return Task

PackAsync() public method

Pack nullable Int64 value asynchronously.
public PackAsync ( System.Int64 value, CancellationToken cancellationToken ) : Task
value System.Int64 Value to serialize.
cancellationToken System.Threading.CancellationToken The token to monitor for cancellation requests. The default value is .
return Task

PackAsync() public method

Pack nullable Single value asynchronously.
public PackAsync ( System.Single value ) : Task
value System.Single Value to serialize.
return Task

PackAsync() public method

Pack nullable Single value asynchronously.
public PackAsync ( System.Single value, CancellationToken cancellationToken ) : Task
value System.Single Value to serialize.
cancellationToken System.Threading.CancellationToken The token to monitor for cancellation requests. The default value is .
return Task

PackAsync() public method

Packs Boolean value to current stream asynchronously.
public PackAsync ( bool value ) : Task
value bool value.
return Task

PackAsync() public method

Packs Boolean value to current stream asynchronously.
public PackAsync ( bool value, CancellationToken cancellationToken ) : Task
value bool value.
cancellationToken System.Threading.CancellationToken The token to monitor for cancellation requests. The default value is .
return Task

PackAsync() public method

Packs Byte value to current stream asynchronously.
This instance has been disposed.
public PackAsync ( byte value ) : Task
value byte value.
return Task

PackAsync() public method

Packs Byte value to current stream asynchronously.
This instance has been disposed.
public PackAsync ( byte value, CancellationToken cancellationToken ) : Task
value byte value.
cancellationToken System.Threading.CancellationToken The token to monitor for cancellation requests. The default value is .
return Task

PackNull() public method

Packs a null value to current stream.
This instance has been disposed.
public PackNull ( ) : Packer
return Packer

PackNullAsync() public method

Packs a null value to current stream asynchronously.
This instance has been disposed.
public PackNullAsync ( ) : Task
return Task

PackNullAsync() public method

Packs a null value to current stream asynchronously.
This instance has been disposed.
public PackNullAsync ( CancellationToken cancellationToken ) : Task
cancellationToken System.Threading.CancellationToken The token to monitor for cancellation requests. The default value is .
return Task

Packer() protected method

Initializes a new instance of the Packer class with DefaultCompatibilityOptions.
protected Packer ( ) : System
return System

Packer() protected method

Initializes a new instance of the Packer class with specified PackerCompatibilityOptions.
protected Packer ( PackerCompatibilityOptions compatibilityOptions ) : System
compatibilityOptions PackerCompatibilityOptions A which specifies compatibility options.
return System

SeekTo() protected method

When overridden by derived class, change current position to specified offset.
/// A class of this instance does not support seek. ///
protected SeekTo ( long offset ) : void
offset long Offset. You shoud not specify the value which causes underflow or overflow.
return void

TryPackInt8() protected method

Try packs SByte value to current stream strictly.
protected TryPackInt8 ( long value ) : bool
value long Maybe value.
return bool

TryPackInt8Async() protected method

Try packs SByte value to current stream strictly asynchronously.
protected TryPackInt8Async ( long value ) : Task
value long Maybe value.
return Task

TryPackInt8Async() protected method

Try packs SByte value to current stream strictly asynchronously.
protected TryPackInt8Async ( long value, CancellationToken cancellationToken ) : Task
value long Maybe value.
cancellationToken System.Threading.CancellationToken The token to monitor for cancellation requests. The default value is .
return Task

TryPackTinySignedInteger() protected method

Try packs SByte value to current stream as tiny fix num.
protected TryPackTinySignedInteger ( long value ) : bool
value long Maybe tiny value.
return bool

TryPackTinySignedIntegerAsync() protected method

Try packs SByte value to current stream as tiny fix num asynchronously.
protected TryPackTinySignedIntegerAsync ( long value ) : Task
value long Maybe tiny value.
return Task

TryPackTinySignedIntegerAsync() protected method

Try packs SByte value to current stream as tiny fix num asynchronously.
protected TryPackTinySignedIntegerAsync ( long value, CancellationToken cancellationToken ) : Task
value long Maybe tiny value.
cancellationToken System.Threading.CancellationToken The token to monitor for cancellation requests. The default value is .
return Task

WriteByte() protected abstract method

When overridden by derived class, writes specified byte to stream using implementation specific manner.
protected abstract WriteByte ( byte value ) : void
value byte A byte to be written.
return void

WriteByteAsync() protected method

When overridden by derived class, writes specified byte to stream using implementation specific manner asynchronously.
protected WriteByteAsync ( byte value ) : Task
value byte A byte to be written.
return Task

WriteByteAsync() protected method

When overridden by derived class, writes specified byte to stream using implementation specific manner asynchronously.
protected WriteByteAsync ( byte value, CancellationToken cancellationToken ) : Task
value byte A byte to be written.
cancellationToken System.Threading.CancellationToken The token to monitor for cancellation requests. The default value is .
return Task

WriteBytesAsync() protected method

Writes specified bytes to stream using implementation specific most efficient manner asynchronously.
protected WriteBytesAsync ( ICollection value ) : Task
value ICollection Collection of bytes to be written.
return Task

WriteBytesAsync() protected method

Writes specified bytes to stream using implementation specific most efficient manner asynchronously.
protected WriteBytesAsync ( ICollection value, CancellationToken cancellationToken ) : Task
value ICollection Collection of bytes to be written.
cancellationToken System.Threading.CancellationToken The token to monitor for cancellation requests. The default value is .
return Task

WriteBytesAsync() protected method

Writes specified bytes to stream using implementation specific most efficient manner asynchronously.
protected WriteBytesAsync ( byte value, bool isImmutable ) : Task
value byte Bytes to be written.
isImmutable bool If the can be treat as immutable (that is, can be used safely without copying) then true.
return Task

WriteBytesAsync() protected method

Writes specified bytes to stream using implementation specific most efficient manner asynchronously.
protected WriteBytesAsync ( byte value, bool isImmutable, CancellationToken cancellationToken ) : Task
value byte Bytes to be written.
isImmutable bool If the can be treat as immutable (that is, can be used safely without copying) then true.
cancellationToken System.Threading.CancellationToken The token to monitor for cancellation requests. The default value is .
return Task