Skip to main content

SalBinary

Namespace: PPJ.Runtime

Assembly: PPJ.Runtime.50 (5.0.0.0)

Wraps a byte array as a SAL binary value.

public class SalBinary : ISalType

The supplied array is retained without copying. Both null and zero-length arrays represent SAL null. Access through ISalType reports DbType.Binary and returns DBNull.Value for a null value.

Example:

using PPJ.Runtime;

byte[] bytes = { 1, 2, 3 };
SalBinary value = new SalBinary(bytes);
SalNumber length = value.Length; // 3
value.Value[0] = 9; // Also changes bytes[0].

SalBinary prefix = SalBinary.Empty;
value.SetBufferLength(ref prefix, 2); // Copies { 9, 2 }.

Constructors

Instance member SalBinary()

Initializes a SAL binary value with a null buffer.

Instance member SalBinary(buffer)

Initializes a binary value using the supplied buffer.

NameTypeDescription
bufferByte[]The byte array to retain, or null. The array is not copied.

Fields

NameTypeDescriptionValue
EmptySalBinaryRepresents the shared empty binary value.

Properties

Instance member IsNull

Boolean: Gets whether the buffer is null or empty.

Instance member Length

SalNumber: Gets the number of bytes in the buffer.

Instance member Value

Byte[]: Gets the underlying byte array.

The returned array is the stored array, not a copy. Modifying its elements changes this value.

Methods

Instance member GetBufferLength()

Returns the number of bytes in the buffer.

Returns: SalNumber. The buffer length, or zero for a null or empty value.

Instance member SetBufferLength(target, length)

Copies a prefix of this buffer into a new binary value.

ParameterTypeDescription
target by referenceSalBinaryReceives the copied prefix, or Empty when the requested length is zero or negative.
lengthInt32The number of bytes to copy. A positive value must not exceed the source buffer length.

Returns: Boolean. True after the target has been assigned.

This method does not pad or grow the source buffer. Throws:

Example:

using PPJ.Runtime;

SalBinary source = new SalBinary(new byte[] { 10, 20, 30, 40 });
SalBinary prefix = SalBinary.Empty;
source.SetBufferLength(ref prefix, 2);
// prefix.Value contains { 10, 20 }; source.Value still contains all four bytes.

source.SetBufferLength(ref prefix, 0); // Assigns SalBinary.Empty.
// A positive length greater than source.Value.Length is invalid.

Implements

NameDescription
ISalTypeExposes a SAL value in the form used for database parameter binding.