Class MacaddrHandler
A type handler for the PostgreSQL macaddr and macaddr8 data types.
Inheritance
Inherited Members
Namespace: Npgsql.Internal.TypeHandlers.NetworkHandlers
Assembly: Npgsql.dll
Syntax
public class MacaddrHandler : NpgsqlSimpleTypeHandler<PhysicalAddress>, INpgsqlTypeHandler<PhysicalAddress>, INpgsqlSimpleTypeHandler<PhysicalAddress>
Remarks
See https://www.postgresql.org/docs/current/static/datatype-net-types.html.
The type handler API allows customizing Npgsql's behavior in powerful ways. However, although it is public, it should be considered somewhat unstable, and may change in breaking ways, including in non-major releases. Use it at your own risk.
Constructors
MacaddrHandler(PostgresType)
Declaration
public MacaddrHandler(PostgresType pgType)
Parameters
Type | Name | Description |
---|---|---|
PostgresType | pgType |
Methods
Read(NpgsqlReadBuffer, Int32, FieldDescription)
Reads a value of type TDefault
with the given length from the provided buffer,
with the assumption that it is entirely present in the provided memory buffer and no I/O will be
required.
Declaration
public override PhysicalAddress Read(NpgsqlReadBuffer buf, int len, FieldDescription fieldDescription = null)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlReadBuffer | buf | The buffer from which to read. |
Int32 | len | The byte length of the value. The buffer might not contain the full length, requiring I/O to be performed. |
FieldDescription | fieldDescription | Additional PostgreSQL information about the type, such as the length in varchar(30). |
Returns
Type | Description |
---|---|
PhysicalAddress | The fully-read value. |
Overrides
ValidateAndGetLength(PhysicalAddress, 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.
Declaration
public override int ValidateAndGetLength(PhysicalAddress value, NpgsqlParameter parameter)
Parameters
Type | Name | Description |
---|---|---|
PhysicalAddress | value | |
NpgsqlParameter | parameter | The NpgsqlParameter instance where this value resides. Can be used to access additional information relevant to the write process (e.g. Size). |
Returns
Type | Description |
---|---|
Int32 | The number of bytes required to write the value. |
Overrides
Write(PhysicalAddress, NpgsqlWriteBuffer, NpgsqlParameter)
Writes a value to the provided buffer, with the assumption that there is enough space in the buffer (no I/O will occur). The Npgsql core will have taken care of that.
Declaration
public override void Write(PhysicalAddress value, NpgsqlWriteBuffer buf, NpgsqlParameter parameter)
Parameters
Type | Name | Description |
---|---|---|
PhysicalAddress | value | |
NpgsqlWriteBuffer | buf | The buffer to which to write. |
NpgsqlParameter | parameter | The NpgsqlParameter instance where this value resides. Can be used to access additional information relevant to the write process (e.g. Size). |