本文整理汇总了C#中SqlBytesCharsState类的典型用法代码示例。如果您正苦于以下问题:C# SqlBytesCharsState类的具体用法?C# SqlBytesCharsState怎么用?C# SqlBytesCharsState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SqlBytesCharsState类属于命名空间,在下文中一共展示了SqlBytesCharsState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SqlChars
internal SqlChars(SqlStreamChars s)
{
this.m_rgchBuf = null;
this.m_lCurLen = -1L;
this.m_stream = s;
this.m_state = (s == null) ? SqlBytesCharsState.Null : SqlBytesCharsState.Stream;
this.m_rgchWorkBuf = null;
}
示例2: SqlBytes
public SqlBytes(System.IO.Stream s)
{
this.m_rgbBuf = null;
this.m_lCurLen = -1L;
this.m_stream = s;
this.m_state = (s == null) ? SqlBytesCharsState.Null : SqlBytesCharsState.Stream;
this.m_rgbWorkBuf = null;
}
示例3: SqlChars
// Create a SqlChars with an in-memory buffer
public SqlChars(char[] buffer)
{
m_rgchBuf = buffer;
m_stream = null;
if (m_rgchBuf == null)
{
_state = SqlBytesCharsState.Null;
_lCurLen = x_lNull;
}
else
{
_state = SqlBytesCharsState.Buffer;
_lCurLen = (long)m_rgchBuf.Length;
}
_rgchWorkBuf = null;
AssertValid();
}
示例4: SqlBytes
// Create a SqlBytes with an in-memory buffer
public SqlBytes(byte[] buffer)
{
_rgbBuf = buffer;
_stream = null;
if (_rgbBuf == null)
{
_state = SqlBytesCharsState.Null;
_lCurLen = x_lNull;
}
else
{
_state = SqlBytesCharsState.Buffer;
_lCurLen = _rgbBuf.Length;
}
_rgbWorkBuf = null;
AssertValid();
}
示例5: CopyStreamToBuffer
private void CopyStreamToBuffer()
{
long length = this.m_stream.Length;
if (length >= 0x7fffffffL)
{
throw new SqlTypeException(System.Data.Res.GetString("SqlMisc_BufferInsufficientMessage"));
}
if ((this.m_rgchBuf == null) || (this.m_rgchBuf.Length < length))
{
this.m_rgchBuf = new char[length];
}
if (this.m_stream.Position != 0L)
{
this.m_stream.Seek(0L, SeekOrigin.Begin);
}
this.m_stream.Read(this.m_rgchBuf, 0, (int) length);
this.m_stream = null;
this.m_lCurLen = length;
this.m_state = SqlBytesCharsState.Buffer;
}
示例6: SqlBytes
// Create a SqlBytes with an in-memory buffer
public SqlBytes(byte[] buffer) {
m_rgbBuf = buffer;
m_stream = null;
if (m_rgbBuf == null) {
m_state = SqlBytesCharsState.Null;
m_lCurLen = x_lNull;
}
else {
m_state = SqlBytesCharsState.Buffer;
m_lCurLen = (long)m_rgbBuf.Length;
}
m_rgbWorkBuf = null;
AssertValid();
}
示例7: CopyStreamToBuffer
// Copy the data from the Stream to the array buffer.
// If the SqlChars doesn't hold a buffer or the buffer
// is not big enough, allocate new char array.
private void CopyStreamToBuffer() {
Debug.Assert(FStream());
long lStreamLen = m_stream.Length;
if (lStreamLen >= x_lMaxLen)
throw new SqlTypeException(Res.GetString(Res.SqlMisc_BufferInsufficientMessage));
if (m_rgchBuf == null || m_rgchBuf.Length < lStreamLen)
m_rgchBuf = new char[lStreamLen];
if (m_stream.Position != 0)
m_stream.Seek(0, SeekOrigin.Begin);
m_stream.Read(m_rgchBuf, 0, (int)lStreamLen);
m_stream = null;
m_lCurLen = lStreamLen;
m_state = SqlBytesCharsState.Buffer;
AssertValid();
}
示例8: SetLength
// Set the current length of the data
// If the SqlChars is Null, setLength will make it non-Null.
public void SetLength(long value) {
if (value < 0)
throw new ArgumentOutOfRangeException("value");
if (FStream()) {
m_stream.SetLength(value);
}
else {
// If there is a buffer, even the value of SqlChars is Null,
// still allow setting length to zero, which will make it not Null.
// If the buffer is null, raise exception
//
if (null == m_rgchBuf)
throw new SqlTypeException(Res.GetString(Res.SqlMisc_NoBufferMessage));
if (value > (long)m_rgchBuf.Length)
throw new ArgumentOutOfRangeException("value");
else if (IsNull)
// At this point we know that value is small enough
// Go back in buffer mode
m_state = SqlBytesCharsState.Buffer;
m_lCurLen = value;
}
AssertValid();
}
示例9: SetBuffer
private void SetBuffer(char[] buffer)
{
this.m_rgchBuf = buffer;
this.m_lCurLen = (this.m_rgchBuf == null) ? -1L : ((long) this.m_rgchBuf.Length);
this.m_stream = null;
this.m_state = (this.m_rgchBuf == null) ? SqlBytesCharsState.Null : SqlBytesCharsState.Buffer;
}
示例10: SetBuffer
private void SetBuffer(byte[] buffer)
{
_rgbBuf = buffer;
_lCurLen = (_rgbBuf == null) ? x_lNull : _rgbBuf.Length;
_stream = null;
_state = (_rgbBuf == null) ? SqlBytesCharsState.Null : SqlBytesCharsState.Buffer;
AssertValid();
}
示例11: CopyStreamToBuffer
// Copy the data from the Stream to the array buffer.
// If the SqlBytes doesn't hold a buffer or the buffer
// is not big enough, allocate new byte array.
private void CopyStreamToBuffer()
{
Debug.Assert(FStream());
long lStreamLen = _stream.Length;
if (lStreamLen >= x_lMaxLen)
throw new SqlTypeException(SR.SqlMisc_WriteOffsetLargerThanLenMessage);
if (_rgbBuf == null || _rgbBuf.Length < lStreamLen)
_rgbBuf = new byte[lStreamLen];
if (_stream.Position != 0)
_stream.Seek(0, SeekOrigin.Begin);
_stream.Read(_rgbBuf, 0, (int)lStreamLen);
_stream = null;
_lCurLen = lStreamLen;
_state = SqlBytesCharsState.Buffer;
AssertValid();
}
示例12: SqlChars
// Create a SqlChars from a SqlStreamChars
internal SqlChars(SqlStreamChars s) {
m_rgchBuf = null;
m_lCurLen = x_lNull;
m_stream = s;
m_state = (s == null) ? SqlBytesCharsState.Null : SqlBytesCharsState.Stream;
m_rgchWorkBuf = null;
AssertValid();
}
示例13: SetNull
// --------------------------------------------------------------
// Public methods
// --------------------------------------------------------------
public void SetNull() {
m_lCurLen = x_lNull;
m_stream = null;
m_state = SqlBytesCharsState.Null;
AssertValid();
}
示例14: SetLength
public void SetLength(long value)
{
if (value < 0L)
{
throw new ArgumentOutOfRangeException("value");
}
if (this.FStream())
{
this.m_stream.SetLength(value);
}
else
{
if (this.m_rgchBuf == null)
{
throw new SqlTypeException(System.Data.Res.GetString("SqlMisc_NoBufferMessage"));
}
if (value > this.m_rgchBuf.Length)
{
throw new ArgumentOutOfRangeException("value");
}
if (this.IsNull)
{
this.m_state = SqlBytesCharsState.Buffer;
}
this.m_lCurLen = value;
}
}
示例15: Write
// Write data of specified length into the SqlChars from specified offset
public void Write(long offset, char[] buffer, int offsetInBuffer, int count) {
if (FStream()) {
if (m_stream.Position != offset)
m_stream.Seek(offset, SeekOrigin.Begin);
m_stream.Write(buffer, offsetInBuffer, count);
}
else {
// Validate the arguments
if (buffer == null)
throw new ArgumentNullException("buffer");
if (m_rgchBuf == null)
throw new SqlTypeException(Res.GetString(Res.SqlMisc_NoBufferMessage));
if (offset < 0)
throw new ArgumentOutOfRangeException("offset");
if (offset > m_rgchBuf.Length)
throw new SqlTypeException(Res.GetString(Res.SqlMisc_BufferInsufficientMessage));
if (offsetInBuffer < 0 || offsetInBuffer > buffer.Length)
throw new ArgumentOutOfRangeException("offsetInBuffer");
if (count < 0 || count > buffer.Length - offsetInBuffer)
throw new ArgumentOutOfRangeException("count");
if (count > m_rgchBuf.Length - offset)
throw new SqlTypeException(Res.GetString(Res.SqlMisc_BufferInsufficientMessage));
if (IsNull) {
// If NULL and there is buffer inside, we only allow writing from
// offset zero.
//
if (offset != 0)
throw new SqlTypeException(Res.GetString(Res.SqlMisc_WriteNonZeroOffsetOnNullMessage));
// treat as if our current length is zero.
// Note this has to be done after all inputs are validated, so that
// we won't throw exception after this point.
//
m_lCurLen = 0;
m_state = SqlBytesCharsState.Buffer;
}
else if (offset > m_lCurLen) {
// Don't allow writing from an offset that this larger than current length.
// It would leave uninitialized data in the buffer.
//
throw new SqlTypeException(Res.GetString(Res.SqlMisc_WriteOffsetLargerThanLenMessage));
}
if (count != 0) {
Array.Copy(buffer, offsetInBuffer, m_rgchBuf, offset, count);
// If the last position that has been written is after
// the current data length, reset the length
if (m_lCurLen < offset + count)
m_lCurLen = offset + count;
}
}
AssertValid();
}