ASN1C C# Runtime Library  7.6
Public Member Functions | Properties | List of all members
Asn1OutputStream Class Reference
Inheritance diagram for Asn1OutputStream:
Asn1BerOutputStream Asn1MderOutputStream Asn1PerOutputStream Asn1XerOutputStream Asn1XmlOutputStream Asn1CerOutputStream

Public Member Functions

 Asn1OutputStream (System.IO.Stream os)
 
override void Close ()
 
override void Flush ()
 
override int Read (byte[] buffer, int offset, int count)
 
override long Seek (long offset, System.IO.SeekOrigin origin)
 
override void SetLength (long value)
 
virtual void Write (byte[] b)
 
override void Write (System.Byte[] b, int off, int len)
 
void Write2Bytes (int value)
 
void Write4Bytes (int value)
 
virtual void WriteByte (int b)
 
override void WriteByte (byte b)
 

Properties

override bool CanRead [get]
 
override bool CanSeek [get]
 
override bool CanWrite [get]
 
Asn1Context Context [get]
 
override long Length [get]
 
override long Position [get, set]
 

Detailed Description

This abstract class implements the base output stream to encode ASN.1 messages.

Constructor & Destructor Documentation

◆ Asn1OutputStream()

Asn1OutputStream ( System.IO.Stream  os)

This constructor creates an output stream object.

Parameters
osThe underlying System.IO.Stream object.

Member Function Documentation

◆ Close()

override void Close ( )

Closes this output stream and releases any system resources associated with this stream. The general contract of close is that it closes the output stream. A closed stream cannot perform output operations and cannot be reopened.

Exceptions
System.IO.IOExceptionAn error occurred while trying to close the stream.

◆ Flush()

override void Flush ( )

Flushes this output stream and forces any buffered output bytes to be written out. The general contract of flush is that calling it is an indication that, if any bytes previously written have been buffered by the implementation of the output stream, such bytes should immediately be written to their intended destination.

Exceptions
System.IO.IOExceptionAn I/O error occurs.
System.ObjectDisposedExceptionThe stream is closed.

◆ Read()

override int Read ( byte []  buffer,
int  offset,
int  count 
)

This method always throws NotSupportedException. Asn1OutputStream doesn't support reading.

Parameters
bufferWhen this method returns, contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current source.
offsetThe byte offset in array at which to begin reading.
countThe maximum number of bytes to read.
Returns
The total number of bytes read into the buffer.
Exceptions
System.NotSupportedExceptionThe stream does not support reading.

◆ Seek()

override long Seek ( long  offset,
System.IO.SeekOrigin  origin 
)

Sets the current position of this stream to the given value.

Parameters
offsetThe point relative to origin from which to begin seeking.
originSpecifies the beginning, the end, or the current position as a reference point for origin, using a value of type SeekOrigin.
Returns
The new position in the stream.
Exceptions
System.IO.IOExceptionAn I/O error occurs.
System.NotSupportedExceptionThe stream does not support seeking, such as if the FileStream is constructed from a pipe or console output.
System.ArgumentExceptionAttempted seeking before the beginning of the stream.
System.ObjectDisposedExceptionMethods were called after the stream was closed.

◆ SetLength()

override void SetLength ( long  value)

Sets the length of this stream to the given value.

Parameters
valueThe new length of the stream.
Exceptions
System.IO.IOExceptionAn I/O error has occurred.
System.NotSupportedExceptionThe stream does not support both writing and seeking.
System.ArgumentOutOfRangeExceptionAttempted to set the value parameter to less than 0.

◆ Write() [1/2]

virtual void Write ( byte []  b)
virtual

Writes b.length bytes from the specified byte array to this output stream. The general contract for write(b) is that it should have exactly the same effect as the call Write(b, 0, b.length).

Parameters
bthe data.
Exceptions
System.ArgumentNullExceptionarray is a null reference
System.ArgumentExceptionoffset and count describe an invalid range in array.
System.ArgumentOutOfRangeExceptionoffset or count is negative.
System.IO.IOExceptionAn I/O error occurs.
System.ObjectDisposedExceptionThe stream is closed.
System.NotSupportedExceptionThe current stream instance does not support writing.

Reimplemented in Asn1PerOutputStream.

Referenced by Asn1Real10.ConvertToDecimal(), Asn1BigInteger.DecodeXML(), Asn1UTF8String.Encode(), Asn1OctetString.Encode(), Asn1BitString.Encode(), Asn1Real10.Encode(), and Asn1OpenType.ToString().

◆ Write() [2/2]

override void Write ( System.Byte []  b,
int  off,
int  len 
)

Writes len bytes from the specified byte array starting at offset off to this output stream.

Parameters
bThe byte array data to be written.
offThe offset in array at which to begin write.
lenthe number of bytes to write.
Exceptions
System.ArgumentNullExceptionarray is a null reference
System.ArgumentExceptionoffset and count describe an invalid range in array.
System.ArgumentOutOfRangeExceptionoffset or count is negative.
System.IO.IOExceptionAn I/O error occurs.
System.ObjectDisposedExceptionThe stream is closed.
System.NotSupportedExceptionThe current stream instance does not support writing.

◆ Write2Bytes()

void Write2Bytes ( int  value)

Write the lowest two bytes of value to the output stream. The lowest byte is written last.

Parameters
value

Referenced by Asn1OctetString.Encode(), and Asn1Integer.Encode16Bit().

◆ Write4Bytes()

void Write4Bytes ( int  value)

Write the four bytes of value to the output stream. The lowest byte is written last.

Parameters
value

Referenced by Asn1Integer.Encode32Bit().

◆ WriteByte() [1/2]

virtual void WriteByte ( int  b)
virtual

Writes the specified byte to this output stream. The general contract for Write is that one byte is written to the output stream. The byte to be written is the eight low-order bits of the argument b. The 24 high-order bits of b are ignored.

Parameters
bthe byte.
Exceptions
System.ObjectDisposedExceptionThe stream is closed.
System.NotSupportedExceptionThe stream does not support writing.

Reimplemented in Asn1PerOutputStream.

Referenced by Asn1Real10.ConvertToDecimal(), Asn1Real10.Encode(), Asn1Integer.Encode(), Asn1Real.NormalizedRealValueToString(), and Asn1Boolean.ToString().

◆ WriteByte() [2/2]

override void WriteByte ( byte  b)

Writes the specified byte to this output stream. The general contract for Write is that one byte is written to the output stream. The byte to be written is the eight low-order bits of the argument b. The 24 high-order bits of b are ignored.

Parameters
bthe byte.
Exceptions
System.ObjectDisposedExceptionThe stream is closed.
System.NotSupportedExceptionThe stream does not support writing.

Property Documentation

◆ CanRead

override bool CanRead
get

Gets a value indicating whether the current stream supports reading.

Value: false, the stream doesn't supports reading.

◆ CanSeek

override bool CanSeek
get

Gets a value indicating whether the current stream supports seeking.

Value: true if the stream supports seeking; otherwise, false.

◆ CanWrite

override bool CanWrite
get

Gets a value indicating whether the current stream supports writing.

Value: true if the stream supports writing; otherwise, false.

◆ Context

Asn1Context Context
get

The context associated with this output stream.

◆ Length

override long Length
get

Gets the length in bytes of the stream.

Value: A long value representing the length of the stream in bytes.

Exceptions
System.NotSupportedExceptionCanSeek for this stream is false.
System.IO.IOExceptionAn I/O error occurs, such as the file being closed.

◆ Position

override long Position
getset

Gets or sets the current position of this stream.

Value: The current position of this stream.

Exceptions
System.NotSupportedExceptionThe stream does not support seeking.
System.IO.IOExceptionAn I/O error occurs.
System.ArgumentOutOfRangeExceptionAttempted to set the position to a negative value.
System.IO.EndOfStreamExceptionAttempted seeking past the end of a stream that does not support this.