Example #1
0
    public void FillBytes(SqlBytes value)
    {
        if (fIsNull)
        {
            if (value.IsNull)
            {
                return;
            }
            else
            {
                value.SetNull();
                return;
            }
        }

        byte[] bigbytes = new byte[9];
        byte[] bytes    = BitConverter.GetBytes(x);
        bytes.CopyTo(bigbytes, 0);
        bytes = BitConverter.GetBytes(y);
        bytes.CopyTo(bigbytes, 4);

        int i;

        for (i = 0; i < bigbytes.Length; i++)
        {
            value[i] = bigbytes[i];
        }
        value.SetLength(i);

        return;
    }
Example #2
0
    public void FillBytes(SqlBytes data)
    {
        if (fIsNull)
        {
            if (data.IsNull)
            {
                return;
            }
            else
            {
                data.SetNull();
                return;
            }
        }

        byte[] bigbytes = new byte[16];
        byte[] bytes    = BitConverter.GetBytes(start.X);
        bytes.CopyTo(bigbytes, 0);
        bytes = BitConverter.GetBytes(start.Y);
        bytes.CopyTo(bigbytes, 4);

        bytes = BitConverter.GetBytes(end.X);
        bytes.CopyTo(bigbytes, 8);
        bytes = BitConverter.GetBytes(end.Y);
        bytes.CopyTo(bigbytes, 12);

        int i;

        for (i = 0; i < bigbytes.Length; i++)
        {
            data[i] = bigbytes[i];
        }
        data.SetLength(i);
    }
Example #3
0
        public void SqlBytesSetNull()
        {
            byte[]   b1    = new byte[10];
            SqlBytes bytes = new SqlBytes(b1);

            Assert.Equal(10, bytes.Length);
            bytes.SetNull();
            Assert.Throws <SqlNullValueException>(() => bytes.Length);
            Assert.True(bytes.IsNull);
        }
Example #4
0
        public void SqlBytesSetNull()
        {
            byte []  b1    = new byte [10];
            SqlBytes bytes = new SqlBytes(b1);

            Assert.AreEqual(bytes.Length, 10, "#1 Should be same");
            bytes.SetNull();
            try {
                Assert.AreEqual(bytes.Length, 10, "#1 Should not be same");
                Assert.Fail("Should throw SqlNullValueException");
            } catch (Exception ex) {
                Assert.AreEqual(typeof(SqlNullValueException), ex.GetType(), "Should throw SqlNullValueException");
            }
            Assert.AreEqual(true, bytes.IsNull, "#2 Should be same");
        }
Example #5
0
        public void SqlBytesSetNull()
        {
            byte[]   b1    = new byte[10];
            SqlBytes bytes = new SqlBytes(b1);

            Assert.Equal(bytes.Length, 10);
            bytes.SetNull();
            try
            {
                Assert.Equal(bytes.Length, 10);
                Assert.False(true);
            }
            catch (Exception ex)
            {
                Assert.Equal(typeof(SqlNullValueException), ex.GetType());
            }
            Assert.Equal(true, bytes.IsNull);
        }
Example #6
0
    public void FillBytes(SqlBytes value)
    {
        if (IsNull)
        {
            if (value.IsNull)
            {
                return;
            }
            else
            {
                value.SetNull();
                return;
            }
        }

        SqlString str;

        if ((object)m_secondline == null || m_secondline.IsNull)
        {
            str = m_firstline;
        }
        else
        {
            str = string.Concat(m_firstline, "|");
            str = string.Concat(str, m_secondline);
        }

        byte[] stringData = str.GetUnicodeBytes();
        int    i;

        for (i = 0; i < stringData.Length; i++)
        {
            value[i] = stringData[i];
        }
        value.SetLength(i);

        return;
    }