Struct DecodingContext
Represents text decoding context.
Inherited Members
Namespace: DotNext.Text
Assembly: DotNext.IO.dll
Syntax
public readonly struct DecodingContext : ICloneable, IResettable
Remarks
The context represents a decoding cache to avoid memory allocations for each round of string decoding caused by methods of StreamExtensions class. It cannot be shared across parallel flows or threads. However, you can call Copy() method to create an independent copy of this context for separated async flow or thread.
Constructors
| Edit this page View SourceDecodingContext(Encoding, bool)
Represents text decoding context.
Declaration
public DecodingContext(Encoding encoding, bool reuseDecoder)
Parameters
Type | Name | Description |
---|---|---|
Encoding | encoding | The encoding to be used for converting bytes into string. |
bool | reuseDecoder | true to reuse the decoder between decoding operations; false to create separated encoder for each encoding operation. |
Remarks
The context represents a decoding cache to avoid memory allocations for each round of string decoding caused by methods of StreamExtensions class. It cannot be shared across parallel flows or threads. However, you can call Copy() method to create an independent copy of this context for separated async flow or thread.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Properties
| Edit this page View SourceEncoding
Gets encoding associated with this context.
Declaration
public Encoding Encoding { get; }
Property Value
Type | Description |
---|---|
Encoding |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Methods
| Edit this page View SourceCopy()
Creates independent copy of this context that can be used in separated async flow or thread.
Declaration
public DecodingContext Copy()
Returns
Type | Description |
---|---|
DecodingContext | The independent copy of this context. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Reset()
Sets the encapsulated decoder to its initial state.
Declaration
public void Reset()
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Operators
| Edit this page View Sourceimplicit operator DecodingContext(Encoding)
Creates decoding context.
Declaration
public static implicit operator DecodingContext(Encoding encoding)
Parameters
Type | Name | Description |
---|---|---|
Encoding | encoding | The text encoding. |
Returns
Type | Description |
---|---|
DecodingContext |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|