Esempio n. 1
0
        void WriteArray2(FakeStruct fake, int offset, DataFieldInfo info, IntPtr ptr)
        {
            var    buffer = fake.buffer;
            object value;

            value = UnsafeOperation.GetObject(ptr + info.MemOffset);
            if (value == null)
            {
                return;
            }
            int a = info.DBType & 31;

            switch (a)
            {
            case DataType2.Byte:
                fake[offset] = WriteArray2 <byte>(value, buffer, DataType.ByteArray);
                break;

            case DataType2.Int16:
                fake[offset] = WriteArray2 <Int16>(value, buffer, DataType.ByteArray);
                break;

            case DataType2.Int32:
                fake[offset] = WriteArray2 <Int32>(value, buffer, DataType.ByteArray);
                break;

            case DataType2.Float:
                fake[offset] = WriteArray2 <float>(value, buffer, DataType.ByteArray);
                break;

            case DataType2.String:
                fake[offset] = WriteStringArray2(value, buffer, DataType.ByteArray);
                break;

            case DataType2.Int64:
                fake[offset] = WriteArray2 <Int64>(value, buffer, DataType.ByteArray);
                break;

            case DataType2.Double:
                fake[offset] = WriteArray2 <Double>(value, buffer, DataType.ByteArray);
                break;

            case DataType2.Class:
                fake[offset] = WriteClassArray2(value, fake.buffer, info);
                break;

            case DataType2.Struct:
                fake[offset] = WriteStructArray2(value, fake.buffer, info);
                break;
            }
        }
Esempio n. 2
0
        void WriteField(FakeStruct fake, int start, DataFieldInfo info, IntPtr ptr)
        {
            int offset = start + info.DataOffset;

            if (info.DBType < 32)
            {
                if (info.DBType < 16)//数值
                {
                    WriteValue(fake, offset, info, ptr);
                }
                else//引用类型
                {
                    if (info.DBType == DataType2.String)
                    {
                        var obj = UnsafeOperation.GetObject(ptr + info.MemOffset);
                        if (obj != null)
                        {
                            fake[offset] = fake.buffer.AddData(obj, DataType.String);
                        }
                    }
                    else
                    {
                        var obj = UnsafeOperation.GetObject(ptr + info.MemOffset);
                        if (obj != null)
                        {
                            fake[offset] = WriteObject(info.TypeFullName, obj, fake.buffer);
                        }
                    }
                }
            }
            else if (info.DBType < 64)//数组
            {
                WriteArray(fake, offset, info, ptr);
            }
            else//二维数组
            {
                WriteArray2(fake, offset, info, ptr);
            }
        }
Esempio n. 3
0
        void WriteArray(FakeStruct fake, int offset, DataFieldInfo info, IntPtr ptr)
        {
            var    buffer = fake.buffer;
            object value;

            value = UnsafeOperation.GetObject(ptr + info.MemOffset);
            if (value == null)
            {
                return;
            }
            int a = info.DBType & 31;

            if (info.TypeName == DataType2.List)
            {
                switch (a)
                {
                case DataType2.Byte:
                    fake[offset] = buffer.AddData(ToArray <byte>(value), DataType.ByteArray);
                    break;

                case DataType2.Int16:
                    fake[offset] = buffer.AddData(ToArray <Int16>(value), DataType.Int16Array);
                    break;

                case DataType2.Int32:
                    fake[offset] = buffer.AddData(ToArray <Int32>(value), DataType.Int32Array);
                    break;

                case DataType2.Float:
                    fake[offset] = buffer.AddData(ToArray <float>(value), DataType.FloatArray);
                    break;

                case DataType2.String:
                {
                    string[] str = ToArray <string>(value);
                    if (str != null)
                    {
                        fake[offset] = buffer.AddData(new FakeStringArray(str), DataType.FakeStringArray);
                    }
                }
                break;

                case DataType2.Int64:
                    fake[offset] = buffer.AddData(ToArray <Int64>(value), DataType.Int64Array);
                    break;

                case DataType2.Double:
                    fake[offset] = buffer.AddData(ToArray <Double>(value), DataType.DoubleArray);
                    break;

                case DataType2.Class:
                    fake[offset] = WriteClassArray(value, fake.buffer, info.typeInfo);
                    break;

                case DataType2.Struct:
                    fake[offset] = WriteStructList(value, fake.buffer, info.typeInfo);
                    break;
                }
            }
            else
            {
                switch (a)
                {
                case DataType2.Byte:
                    fake[offset] = buffer.AddData(value, DataType.ByteArray);
                    break;

                case DataType2.Int16:
                    fake[offset] = buffer.AddData(value, DataType.Int16Array);
                    break;

                case DataType2.Int32:
                    fake[offset] = buffer.AddData(value, DataType.Int32Array);
                    break;

                case DataType2.Float:
                    fake[offset] = buffer.AddData(value, DataType.FloatArray);
                    break;

                case DataType2.String:
                    fake[offset] = buffer.AddData(new FakeStringArray(value as string[]), DataType.FakeStringArray);
                    break;

                case DataType2.Int64:
                    fake[offset] = buffer.AddData(value, DataType.Int64Array);
                    break;

                case DataType2.Double:
                    fake[offset] = buffer.AddData(value, DataType.DoubleArray);
                    break;

                case DataType2.Class:
                    fake[offset] = WriteClassArray(value, fake.buffer, info.typeInfo);
                    break;

                case DataType2.Struct:
                    fake[offset] = WriteStructArray(value, fake.buffer, info.typeInfo);
                    break;
                }
            }
        }