Exemplo n.º 1
0
    public static int GetDataLong(IntPtr l) //3个参数(WDBData,index,wdbIndex)
    {
        WDBData db       = (WDBData)lua_.ToUserDataObject(-3);
        int     index    = lua_.ToInteger(-2);
        int     wdbIndex = lua_.ToInteger(-1);

        long longValue = db.GetData <long>(index, wdbIndex);

        lua_.PushLongInterger(longValue);
        return(1);
    }
Exemplo n.º 2
0
    public object GetDataByNumber(int row, int field)
    {
        object obj = null;

        if (row >= 0 && row < GetRecordCount() &&
            field >= 0 && field < GetFieldCount())
        {
            int data_offset = mDataOffset + row * mHeader.nRecordSize;
            int n           = 0;
            if (GetFieldType(field) == (int)EWDB_FIELD_TYPE.WFT_FLOAT)
            {
                //obj = BitConverter.ToSingle(mData, data_offset + field * sizeof(int));



                fixed(byte *p = &mData[data_offset + GetOffsetInRecord(field)])
                {
                    obj = *((float *)p);
                }

                return(obj);
            }
            else if (GetFieldType(field) == (int)EWDB_FIELD_TYPE.WFT_LONG)
            {
                long l = 0;
                fixed(byte *p = &mData[data_offset + GetOffsetInRecord(field)])
                {
                    l = *((long *)p);
                }

                return(l);
            }
            else
            {
                //obj = BitConverter.ToInt32(mData, data_offset + field * sizeof(int));

                fixed(byte *p = &mData[data_offset + GetOffsetInRecord(field)])
                {
                    n = *((int *)p);
                }
            }

            if (GetFieldType(field) == (int)EWDB_FIELD_TYPE.WFT_STRING)
            {
                int nextstrindex = 0, count = 0;
                int strindex = n + mStringOffset;

                if (GetNDBStrLen(mData, strindex, ref nextstrindex, ref count))
                {
                    obj = Encoding.Unicode.GetString(mData, strindex, count);
                }
            }
            else if (GetFieldType(field) == (int)EWDB_FIELD_TYPE.WFT_STRINGTABLE)
            {
                int strindex = n;
                obj = mTBl.GetData(strindex, 0);
            }
            else
            {
                return(n);
            }
        }
        return(obj);
    }