Class TextHandler
- Namespace
- Npgsql.TypeHandlers
- Assembly
- Npgsql.dll
public class TextHandler : NpgsqlTypeHandler<string>, INpgsqlTypeHandler<string>, INpgsqlTypeHandler<char[]>, INpgsqlTypeHandler<ArraySegment<char>>, INpgsqlTypeHandler<char>, INpgsqlTypeHandler<byte[]>
- Inheritance
-
TextHandler
- Implements
- Derived
- Inherited Members
Constructors
TextHandler(NpgsqlConnection)
protected TextHandler(NpgsqlConnection connection)
Parameters
connection
NpgsqlConnection
Methods
GetTextReader(Stream)
public virtual TextReader GetTextReader(Stream stream)
Parameters
stream
Stream
Returns
Read(NpgsqlReadBuffer, int, bool, FieldDescription)
Reads a value of type string with the given length from the provided buffer, using either sync or async I/O.
public override ValueTask<string> Read(NpgsqlReadBuffer buf, int byteLen, bool async, FieldDescription fieldDescription = null)
Parameters
buf
NpgsqlReadBufferThe buffer from which to read.
byteLen
intasync
boolIf I/O is required to read the full length of the value, whether it should be performed synchronously or asynchronously.
fieldDescription
FieldDescriptionAdditional PostgreSQL information about the type, such as the length in varchar(30).
Returns
- ValueTask<string>
The fully-read value.
ValidateAndGetLength(ArraySegment<char>, ref NpgsqlLengthCache, NpgsqlParameter)
Responsible for validating that a value represents a value of the correct and which can be written for PostgreSQL - if the value cannot be written for any reason, an exception shold be thrown. Also returns the byte length needed to write the value.
public virtual int ValidateAndGetLength(ArraySegment<char> value, ref NpgsqlLengthCache lengthCache, NpgsqlParameter parameter)
Parameters
value
ArraySegment<char>The value to be written to PostgreSQL
lengthCache
NpgsqlLengthCacheA cache where the length calculated during the validation phase can be stored for use at the writing phase.
parameter
NpgsqlParameterThe NpgsqlParameter instance where this value resides. Can be used to access additional information relevant to the write process (e.g. Size).
Returns
- int
The number of bytes required to write the value.
ValidateAndGetLength(byte[], ref NpgsqlLengthCache, NpgsqlParameter)
Responsible for validating that a value represents a value of the correct and which can be written for PostgreSQL - if the value cannot be written for any reason, an exception shold be thrown. Also returns the byte length needed to write the value.
public int ValidateAndGetLength(byte[] value, ref NpgsqlLengthCache lengthCache, NpgsqlParameter parameter)
Parameters
value
byte[]The value to be written to PostgreSQL
lengthCache
NpgsqlLengthCacheA cache where the length calculated during the validation phase can be stored for use at the writing phase.
parameter
NpgsqlParameterThe NpgsqlParameter instance where this value resides. Can be used to access additional information relevant to the write process (e.g. Size).
Returns
- int
The number of bytes required to write the value.
ValidateAndGetLength(char, ref NpgsqlLengthCache, NpgsqlParameter)
Responsible for validating that a value represents a value of the correct and which can be written for PostgreSQL - if the value cannot be written for any reason, an exception shold be thrown. Also returns the byte length needed to write the value.
public int ValidateAndGetLength(char value, ref NpgsqlLengthCache lengthCache, NpgsqlParameter parameter)
Parameters
value
charThe value to be written to PostgreSQL
lengthCache
NpgsqlLengthCacheA cache where the length calculated during the validation phase can be stored for use at the writing phase.
parameter
NpgsqlParameterThe NpgsqlParameter instance where this value resides. Can be used to access additional information relevant to the write process (e.g. Size).
Returns
- int
The number of bytes required to write the value.
ValidateAndGetLength(char[], ref NpgsqlLengthCache, NpgsqlParameter)
Responsible for validating that a value represents a value of the correct and which can be written for PostgreSQL - if the value cannot be written for any reason, an exception shold be thrown. Also returns the byte length needed to write the value.
public virtual int ValidateAndGetLength(char[] value, ref NpgsqlLengthCache lengthCache, NpgsqlParameter parameter)
Parameters
value
char[]The value to be written to PostgreSQL
lengthCache
NpgsqlLengthCacheA cache where the length calculated during the validation phase can be stored for use at the writing phase.
parameter
NpgsqlParameterThe NpgsqlParameter instance where this value resides. Can be used to access additional information relevant to the write process (e.g. Size).
Returns
- int
The number of bytes required to write the value.
ValidateAndGetLength(string, ref NpgsqlLengthCache, NpgsqlParameter)
Called to validate and get the length of a value of a generic NpgsqlParameter<T>.
public override int ValidateAndGetLength(string value, ref NpgsqlLengthCache lengthCache, NpgsqlParameter parameter)
Parameters
value
stringlengthCache
NpgsqlLengthCacheparameter
NpgsqlParameter
Returns
Write(ArraySegment<char>, NpgsqlWriteBuffer, NpgsqlLengthCache, NpgsqlParameter, bool)
Writes a value to the provided buffer.
public virtual Task Write(ArraySegment<char> value, NpgsqlWriteBuffer buf, NpgsqlLengthCache lengthCache, NpgsqlParameter parameter, bool async)
Parameters
value
ArraySegment<char>The value to write.
buf
NpgsqlWriteBufferThe buffer to which to write.
lengthCache
NpgsqlLengthCacheA cache where the length calculated during the validation phase can be stored for use at the writing phase.
parameter
NpgsqlParameterThe NpgsqlParameter instance where this value resides. Can be used to access additional information relevant to the write process (e.g. Size).
async
boolIf I/O will be necessary (i.e. the buffer is full), determines whether it will be done synchronously or asynchronously.
Returns
Write(byte[], NpgsqlWriteBuffer, NpgsqlLengthCache, NpgsqlParameter, bool)
Writes a value to the provided buffer.
public Task Write(byte[] value, NpgsqlWriteBuffer buf, NpgsqlLengthCache lengthCache, NpgsqlParameter parameter, bool async)
Parameters
value
byte[]The value to write.
buf
NpgsqlWriteBufferThe buffer to which to write.
lengthCache
NpgsqlLengthCacheA cache where the length calculated during the validation phase can be stored for use at the writing phase.
parameter
NpgsqlParameterThe NpgsqlParameter instance where this value resides. Can be used to access additional information relevant to the write process (e.g. Size).
async
boolIf I/O will be necessary (i.e. the buffer is full), determines whether it will be done synchronously or asynchronously.
Returns
Write(char, NpgsqlWriteBuffer, NpgsqlLengthCache, NpgsqlParameter, bool)
Writes a value to the provided buffer.
public Task Write(char value, NpgsqlWriteBuffer buf, NpgsqlLengthCache lengthCache, NpgsqlParameter parameter, bool async)
Parameters
value
charThe value to write.
buf
NpgsqlWriteBufferThe buffer to which to write.
lengthCache
NpgsqlLengthCacheA cache where the length calculated during the validation phase can be stored for use at the writing phase.
parameter
NpgsqlParameterThe NpgsqlParameter instance where this value resides. Can be used to access additional information relevant to the write process (e.g. Size).
async
boolIf I/O will be necessary (i.e. the buffer is full), determines whether it will be done synchronously or asynchronously.
Returns
Write(char[], NpgsqlWriteBuffer, NpgsqlLengthCache, NpgsqlParameter, bool)
Writes a value to the provided buffer.
public virtual Task Write(char[] value, NpgsqlWriteBuffer buf, NpgsqlLengthCache lengthCache, NpgsqlParameter parameter, bool async)
Parameters
value
char[]The value to write.
buf
NpgsqlWriteBufferThe buffer to which to write.
lengthCache
NpgsqlLengthCacheA cache where the length calculated during the validation phase can be stored for use at the writing phase.
parameter
NpgsqlParameterThe NpgsqlParameter instance where this value resides. Can be used to access additional information relevant to the write process (e.g. Size).
async
boolIf I/O will be necessary (i.e. the buffer is full), determines whether it will be done synchronously or asynchronously.
Returns
Write(string, NpgsqlWriteBuffer, NpgsqlLengthCache, NpgsqlParameter, bool)
Called to write the value of a generic NpgsqlParameter<T>.
public override Task Write(string value, NpgsqlWriteBuffer buf, NpgsqlLengthCache lengthCache, NpgsqlParameter parameter, bool async)
Parameters
value
stringbuf
NpgsqlWriteBufferlengthCache
NpgsqlLengthCacheparameter
NpgsqlParameterasync
bool