public static object ObjectFromBytes()

in isam/converter.cs [142:205]


        public static object ObjectFromBytes(JET_coltyp type, bool isASCII, byte[] value)
        {
            if (null == value)
            {
                return DBNull.Value;
            }

            switch (type)
            {
                case JET_coltyp.Nil:
                    throw new ArgumentOutOfRangeException("type", "Nil is not valid");
                case JET_coltyp.Bit:
                    return BitConverter.ToBoolean(value, 0);
                case JET_coltyp.UnsignedByte:
                    return value[0];
                case JET_coltyp.Short:
                    return BitConverter.ToInt16(value, 0);
                case JET_coltyp.Long:
                    return BitConverter.ToInt32(value, 0);
                case VistaColtyp.LongLong:
                    return BitConverter.ToInt64(value, 0);
                case JET_coltyp.Currency:
                    return BitConverter.ToInt64(value, 0);
                case JET_coltyp.IEEESingle:
                    return BitConverter.ToSingle(value, 0);
                case JET_coltyp.IEEEDouble:
                    return BitConverter.ToDouble(value, 0);
                case VistaColtyp.UnsignedShort:
                    return BitConverter.ToUInt16(value, 0);
                case VistaColtyp.UnsignedLong:
                    return BitConverter.ToUInt32(value, 0);
                case JET_coltyp.Binary:
                    return value;
                case JET_coltyp.LongBinary:
                    return value;
                case JET_coltyp.Text:
                    if (isASCII)
                    {
                        return new string(Encoding.ASCII.GetChars(value));
                    }
                    else
                    {
                        return new string(Encoding.Unicode.GetChars(value));
                    }

                case JET_coltyp.LongText:
                    if (isASCII)
                    {
                        return new string(Encoding.ASCII.GetChars(value));
                    }
                    else
                    {
                        return new string(Encoding.Unicode.GetChars(value));
                    }

                case VistaColtyp.GUID:
                    return new Guid(value);
                case JET_coltyp.DateTime:
                    // Internally DateTime is stored as a double, mapping to a COLEDateTime
                    return DateTime.FromOADate(BitConverter.ToDouble(value, 0));
                default:
                    throw new ArgumentOutOfRangeException("type", "unknown type");
            }
        }