예제 #1
0
파일: BlobType.cs 프로젝트: cwdotson/FwNs
        public override object ConvertToType(ISessionInterface session, object a, SqlType othType)
        {
            if (a == null)
            {
                return(null);
            }
            if (othType.TypeCode == 30)
            {
                return(a);
            }
            if ((othType.TypeCode == 60) || (othType.TypeCode == 0x3d))
            {
                IBlobData  data = (IBlobData)a;
                BlobDataId id1  = session.CreateBlob(data.Length(session));
                id1.SetBytes(session, 0L, data.GetBytes());
                return(id1);
            }
            if ((othType.TypeCode != 12) && (othType.TypeCode != 1))
            {
                throw Error.GetError(0x15b9);
            }
            IBlobData  data2 = session.GetScanner().ConvertToBinary((string)a);
            BlobDataId id2   = session.CreateBlob(data2.Length(session));

            id2.SetBytes(session, 0L, data2.GetBytes());
            return(id2);
        }
예제 #2
0
파일: BinaryType.cs 프로젝트: cwdotson/FwNs
        public IBlobData Trim(Session session, IBlobData data, int trim, bool leading, bool trailing)
        {
            if (data == null)
            {
                return(null);
            }
            byte[] bytes  = data.GetBytes();
            int    length = bytes.Length;

            if (trailing)
            {
                length--;
                while ((length >= 0) && (bytes[length] == trim))
                {
                    length--;
                }
                length++;
            }
            int index = 0;

            if (leading)
            {
                while ((index < length) && (bytes[index] == trim))
                {
                    index++;
                }
            }
            byte[] destinationArray = bytes;
            if ((index != 0) || (length != bytes.Length))
            {
                destinationArray = new byte[length - index];
                Array.Copy(bytes, index, destinationArray, 0, length - index);
            }
            if (base.TypeCode == 30)
            {
                BlobDataId id1 = session.CreateBlob((long)destinationArray.Length);
                id1.SetBytes(session, 0L, destinationArray);
                return(id1);
            }
            return(new BinaryData(destinationArray, destinationArray == bytes));
        }
예제 #3
0
파일: BinaryType.cs 프로젝트: cwdotson/FwNs
        public override object Concat(Session session, object a, object b)
        {
            if ((a == null) || (b == null))
            {
                return(null);
            }
            BinaryData data   = a as BinaryData;
            BinaryData data2  = b as BinaryData;
            long       length = data.Length(session) + data2.Length(session);

            if (length > base.Precision)
            {
                throw Error.GetError(0xd49);
            }
            if (base.TypeCode == 30)
            {
                BlobDataId id1 = session.CreateBlob(length);
                id1.SetBytes(session, 0L, data2.GetBytes());
                id1.SetBytes(session, data.Length(session), data2.GetBytes());
                return(id1);
            }
            return(new BinaryData(session, data, data2));
        }