コード例 #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
ファイル: BlobType.cs プロジェクト: cwdotson/FwNs
        public override object ConvertSQLToCSharp(ISessionInterface session, object a)
        {
            IBlobData data1  = (IBlobData)a;
            int       length = (int)data1.Length(session);

            return(data1.GetBytes(session, 0L, length));
        }
コード例 #3
0
ファイル: BinaryType.cs プロジェクト: cwdotson/FwNs
        public virtual IBlobData Substring(ISessionInterface session, IBlobData data, long offset, long length, bool hasLength)
        {
            long num2;
            long num = data.Length(session);

            if (hasLength)
            {
                num2 = offset + length;
            }
            else
            {
                num2 = (num > offset) ? num : offset;
            }
            if (offset > num2)
            {
                throw Error.GetError(0xd67);
            }
            if ((offset > num2) || (num2 < 0L))
            {
                offset = 0L;
                num2   = 0L;
            }
            if (offset < 0L)
            {
                offset = 0L;
            }
            if (num2 > num)
            {
                num2 = num;
            }
            length = num2 - offset;
            return(new BinaryData(data.GetBytes(session, offset, (int)length), false));
        }
コード例 #4
0
ファイル: BinaryType.cs プロジェクト: cwdotson/FwNs
        public virtual IBlobData Overlay(Session session, IBlobData data, IBlobData overlay, long offset, long length, bool hasLength)
        {
            if ((data == null) || (overlay == null))
            {
                return(null);
            }
            if (!hasLength)
            {
                length = overlay.Length(session);
            }
            int typeCode = base.TypeCode;

            if (typeCode == 30)
            {
                byte[]    bytes = this.Substring(session, data, 0L, offset, false).GetBytes();
                long      num2  = (data.Length(session) + overlay.Length(session)) - length;
                IBlobData data3 = session.CreateBlob(num2);
                data3.SetBytes(session, 0L, bytes);
                data3.SetBytes(session, data3.Length(session), overlay.GetBytes());
                bytes = this.Substring(session, data, offset + length, 0L, false).GetBytes();
                data3.SetBytes(session, data3.Length(session), bytes);
                return(data3);
            }
            if ((typeCode - 60) > 1)
            {
                throw Error.RuntimeError(0xc9, "BinaryType");
            }
            return(new BinaryData(session, new BinaryData(session, this.Substring(session, data, 0L, offset, true), overlay), this.Substring(session, data, offset + length, 0L, false)));
        }
コード例 #5
0
ファイル: BinaryData.cs プロジェクト: cwdotson/FwNs
 public long Position(ISessionInterface session, IBlobData pattern, long start)
 {
     if (pattern.Length(session) > this._data.Length)
     {
         return(-1L);
     }
     byte[] bytes = pattern.GetBytes();
     return(this.Position(session, bytes, start));
 }
コード例 #6
0
ファイル: BinaryData.cs プロジェクト: cwdotson/FwNs
        public BinaryData(ISessionInterface session, IBlobData b1, IBlobData b2)
        {
            long num = b1.Length(session) + b2.Length(session);

            if (num > 0x7fffffffL)
            {
                throw Error.GetError(0xd49);
            }
            this._data = new byte[(int)num];
            Array.Copy(b1.GetBytes(), 0, this._data, 0, (int)b1.Length(session));
            Array.Copy(b2.GetBytes(), 0, this._data, (int)b1.Length(session), (int)b2.Length(session));
            this._bitLength = (b1.Length(session) + b2.Length(session)) * 8L;
        }
コード例 #7
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));
        }
コード例 #8
0
ファイル: BinaryType.cs プロジェクト: cwdotson/FwNs
        private object CastOrConvertToType(ISessionInterface session, object a, SqlType otherType, bool cast)
        {
            if (a == null)
            {
                return(null);
            }
            int typeCode = otherType.TypeCode;

            if (typeCode > 12)
            {
                if ((typeCode != 30) && ((typeCode - 60) > 1))
                {
                    goto Label_005A;
                }
                IBlobData data1 = (IBlobData)a;
                goto Label_0065;
            }
            switch (typeCode)
            {
            case 1:
            case 12:
            {
                IBlobData data = session.GetScanner().ConvertToBinary((string)a);
                otherType = GetBinaryType(0x3d, data.Length(session));
                goto Label_0065;
            }
            }
Label_005A:
            throw Error.GetError(0xd8f);
Label_0065:
            if (base.Precision == 0)
            {
                return(null);
            }
            IBlobData data2 = null;

            if ((data2.Length(session) > base.Precision) && (data2.NonZeroLength(session) > base.Precision))
            {
                if (!cast)
                {
                    throw Error.GetError(0xd49);
                }
                session.AddWarning(Error.GetError(0x3ec));
            }
            if (otherType.TypeCode == 30)
            {
                long num2 = data2.Length(session);
                if (num2 > base.Precision)
                {
                    throw Error.GetError(0xd8f);
                }
                data2 = new BinaryData(data2.GetBytes(session, 0L, (int)num2), false);
            }
            int num3 = base.TypeCode;

            if (num3 == 60)
            {
                if (data2.Length(session) > base.Precision)
                {
                    return(new BinaryData(data2.GetBytes(session, 0L, (int)base.Precision), false));
                }
                if (data2.Length(session) < base.Precision)
                {
                    data2 = new BinaryData(ArrayUtil.ResizeArray <byte>(data2.GetBytes(), (int)base.Precision), false);
                }
                return(data2);
            }
            if (num3 != 0x3d)
            {
                throw Error.GetError(0xd8f);
            }
            if (data2.Length(session) > base.Precision)
            {
                data2 = new BinaryData(data2.GetBytes(session, 0L, (int)base.Precision), false);
            }
            return(data2);
        }