Class SshData
- Namespace
- Renci.SshNet.Common
- Assembly
- Renci.SshNet.dll
Base ssh data serialization type.
public abstract class SshData
Inheritance
Derived
Inherited Members
Properties
BufferCapacity
Gets the size of the message in bytes.
protected virtual int BufferCapacity { get; }
Property Value
DataStream
Gets the underlying Renci.SshNet.Common.SshDataStream that is used for reading and writing SSH data.
protected SshDataStream DataStream { get; }
Property Value
IsEndOfData
Gets a value indicating whether all data from the buffer has been read.
protected bool IsEndOfData { get; }
Property Value
Methods
GetBytes()
Gets data bytes array.
public byte[] GetBytes()
Returns
- byte[]
-
A System.Byte array representation of data structure.
Load(byte[])
Loads data from specified bytes.
public void Load(byte[] data)
Parameters
data
byte[]-
Bytes array.
Exceptions
- ArgumentNullException
-
data
is null.
Load(byte[], int, int)
Loads data from the specified buffer.
public void Load(byte[] data, int offset, int count)
Parameters
data
byte[]-
Bytes array.
offset
int-
The zero-based offset in
data
at which to begin reading SSH data. count
int-
The number of bytes to load.
Exceptions
- ArgumentNullException
-
data
is null.
LoadData()
Called when type specific data need to be loaded.
protected abstract void LoadData()
ReadBinary()
Reads next data type as byte array from internal buffer.
protected byte[] ReadBinary()
Returns
- byte[]
-
The bytes read.
ReadBoolean()
Reads the next System.Boolean from the internal buffer.
protected bool ReadBoolean()
Returns
- bool
-
The System.Boolean that was read.
Exceptions
- InvalidOperationException
-
Attempt to read past the end of the stream.
ReadByte()
Reads next byte data type from internal buffer.
protected byte ReadByte()
Returns
- byte
-
The System.Byte read.
Exceptions
- InvalidOperationException
-
Attempt to read past the end of the stream.
ReadBytes()
Reads all data left in internal buffer at current position.
protected byte[] ReadBytes()
Returns
- byte[]
-
An array of bytes containing the remaining data in the internal buffer.
ReadBytes(int)
Reads next specified number of bytes data type from internal buffer.
protected byte[] ReadBytes(int length)
Parameters
length
int-
Number of bytes to read.
Returns
- byte[]
-
An array of bytes that was read from the internal buffer.
Exceptions
- ArgumentOutOfRangeException
-
length
is greater than the number of bytes available to be read.
ReadExtensionPair()
Reads next extension-pair data type from internal buffer.
protected Dictionary<string, string> ReadExtensionPair()
Returns
- Dictionary<string, string>
-
Extensions pair dictionary.
ReadNamesList()
Reads next name-list data type from internal buffer.
protected string[] ReadNamesList()
Returns
- string[]
-
String array or read data.
ReadString(Encoding)
Reads the next System.String from the internal buffer using the specified encoding.
protected string ReadString(Encoding encoding = null)
Parameters
encoding
Encoding-
The character encoding to use.
Returns
- string
-
The System.String that was read.
ReadUInt16()
Reads the next System.UInt16 from the internal buffer.
protected ushort ReadUInt16()
Returns
- ushort
-
The System.UInt16 that was read.
Exceptions
- InvalidOperationException
-
Attempt to read past the end of the stream.
ReadUInt32()
Reads the next System.UInt32 from the internal buffer.
protected uint ReadUInt32()
Returns
- uint
-
The System.UInt32 that was read.
Exceptions
- InvalidOperationException
-
Attempt to read past the end of the stream.
ReadUInt64()
Reads the next System.UInt64 from the internal buffer.
protected ulong ReadUInt64()
Returns
- ulong
-
The System.UInt64 that was read.
Exceptions
- InvalidOperationException
-
Attempt to read past the end of the stream.
SaveData()
Called when type specific data need to be saved.
protected abstract void SaveData()
Write(byte[])
Writes bytes array data into internal buffer.
protected void Write(byte[] data)
Parameters
data
byte[]-
Byte array data to write.
Exceptions
- ArgumentNullException
-
data
is null.
Write(byte[], int, int)
Writes a sequence of bytes to the current SSH data stream and advances the current position within this stream by the number of bytes written.
protected void Write(byte[] buffer, int offset, int count)
Parameters
buffer
byte[]-
An array of bytes. This method write
count
bytes from buffer to the current SSH data stream. offset
int-
The zero-based offset in
buffer
at which to begin writing bytes to the SSH data stream. count
int-
The number of bytes to be written to the current SSH data stream.
Exceptions
- ArgumentNullException
-
buffer
is null. - ArgumentException
-
The sum of
offset
andcount
is greater than the buffer length. - ArgumentOutOfRangeException
-
offset
orcount
is negative.
Write(byte)
Writes System.Byte data into internal buffer.
protected void Write(byte data)
Parameters
data
byte-
System.Byte data to write.
Write(bool)
Writes System.Boolean into internal buffer.
protected void Write(bool data)
Parameters
data
bool-
System.Boolean data to write.
Write(uint)
Writes System.UInt32 data into internal buffer.
protected void Write(uint data)
Parameters
data
uint-
System.UInt32 data to write.
Write(ulong)
Writes System.UInt64 data into internal buffer.
protected void Write(ulong data)
Parameters
data
ulong-
System.UInt64 data to write.
Write(string)
Writes System.String data into internal buffer using default encoding.
protected void Write(string data)
Parameters
data
string-
System.String data to write.
Exceptions
- ArgumentNullException
-
data
is null.
Write(string, Encoding)
Writes System.String data into internal buffer using the specified encoding.
protected void Write(string data, Encoding encoding)
Parameters
Exceptions
- ArgumentNullException
-
data
is null. - ArgumentNullException
-
encoding
is null.
Write(BigInteger)
Writes mpint data into internal buffer.
protected void Write(BigInteger data)
Parameters
data
BigInteger-
mpint data to write.
Write(string[])
Writes name-list data into internal buffer.
protected void Write(string[] data)
Parameters
data
string[]-
name-list data to write.
Write(IDictionary<string, string>)
Writes extension-pair data into internal buffer.
protected void Write(IDictionary<string, string> data)
Parameters
data
IDictionary<string, string>-
extension-pair data to write.
WriteBinary(byte[], int, int)
Writes data into internal buffer.
protected void WriteBinary(byte[] buffer, int offset, int count)
Parameters
buffer
byte[]-
An array of bytes. This method write
count
bytes from buffer to the current SSH data stream. offset
int-
The zero-based byte offset in
buffer
at which to begin writing bytes to the SSH data stream. count
int-
The number of bytes to be written to the current SSH data stream.
Exceptions
- ArgumentNullException
-
buffer
is null. - ArgumentException
-
The sum of
offset
andcount
is greater than the buffer length. - ArgumentOutOfRangeException
-
offset
orcount
is negative.
WriteBinaryString(byte[])
Writes data into internal buffer.
protected void WriteBinaryString(byte[] buffer)
Parameters
buffer
byte[]-
The data to write.
Exceptions
- ArgumentNullException
-
buffer
is null.
WriteBytes(SshDataStream)
Writes the current message to the specified Renci.SshNet.Common.SshDataStream.
protected virtual void WriteBytes(SshDataStream stream)
Parameters
stream
SshDataStream-
The Renci.SshNet.Common.SshDataStream to write the message to.