示例#1
0
            private void SaveByType(LitEngine.IO.AESWriter _writer)
            {
                switch (ValueType)
                {
                case FieldType.Boolean:
                    _writer.WriteBool((bool)dvalue);
                    break;

                case FieldType.Byte:
                    _writer.WriteByte((byte)dvalue);
                    break;

                case FieldType.SByte:
                    _writer.WriteSByte((sbyte)dvalue);
                    break;

                case FieldType.Int16:
                    _writer.WriteShort((short)dvalue);
                    break;

                case FieldType.UInt16:
                    _writer.WriteUShort((ushort)dvalue);
                    break;

                case FieldType.Int32:
                    _writer.WriteInt((int)dvalue);
                    break;

                case FieldType.UInt32:
                    _writer.WriteUInt((uint)dvalue);
                    break;

                case FieldType.Int64:
                    _writer.WriteLong((long)dvalue);
                    break;

                case FieldType.UInt64:
                    _writer.WriteULong((ulong)dvalue);
                    break;

                case FieldType.Single:
                    _writer.WriteFloat((float)dvalue);
                    break;

                case FieldType.Double:
                    _writer.WriteDouble((double)dvalue);
                    break;

                case FieldType.Decimal:
                    _writer.WriteDecimal((decimal)dvalue);
                    break;

                case FieldType.String:
                    _writer.WriteString((string)dvalue);
                    break;

                case FieldType.Char:
                    _writer.WriteChar((char)dvalue);
                    break;

                case FieldType.BigInteger:
                {
                    byte[] tbytes = ((System.Numerics.BigInteger)dvalue).ToByteArray();
                    _writer.WriteInt(tbytes.Length);
                    _writer.WriteBytes(tbytes);
                }
                break;

                case FieldType.Bytes:
                {
                    byte[] tbytes = (byte[])dvalue;
                    _writer.WriteInt(tbytes.Length);
                    _writer.WriteBytes(tbytes);
                }
                break;

                default:
                    DLog.LogWarningFormat("暂不支持的类型,无法存储对应的数据.Key = {0} , Type ={1}", Key, ValueType);
                    break;
                }
            }
示例#2
0
        static public void SaveByType(LitEngine.IO.AESWriter _writer, FieldType pType, object pObject)
        {
            _writer.WriteString(pType.ToString());
            switch (pType)
            {
            case FieldType.Boolean:
                _writer.WriteBool((bool)pObject);
                break;

            case FieldType.Byte:
                _writer.WriteByte((byte)pObject);
                break;

            case FieldType.SByte:
                _writer.WriteSByte((sbyte)pObject);
                break;

            case FieldType.Int16:
                _writer.WriteShort((short)pObject);
                break;

            case FieldType.UInt16:
                _writer.WriteUShort((ushort)pObject);
                break;

            case FieldType.Int32:
                _writer.WriteInt((int)pObject);
                break;

            case FieldType.UInt32:
                _writer.WriteUInt((uint)pObject);
                break;

            case FieldType.Int64:
                _writer.WriteLong((long)pObject);
                break;

            case FieldType.UInt64:
                _writer.WriteULong((ulong)pObject);
                break;

            case FieldType.Single:
                _writer.WriteFloat((float)pObject);
                break;

            case FieldType.Double:
                _writer.WriteDouble((double)pObject);
                break;

            case FieldType.Decimal:
                _writer.WriteDecimal((decimal)pObject);
                break;

            case FieldType.String:
                _writer.WriteString((string)pObject);
                break;

            case FieldType.Char:
                _writer.WriteChar((char)pObject);
                break;

            case FieldType.BigInteger:
            {
                byte[] tbytes = ((System.Numerics.BigInteger)pObject).ToByteArray();
                _writer.WriteInt(tbytes.Length);
                _writer.WriteBytes(tbytes);
            }
            break;

            case FieldType.Bytes:
            {
                byte[] tbytes = (byte[])pObject;
                _writer.WriteInt(tbytes.Length);
                _writer.WriteBytes(tbytes);
            }
            break;

            default:
                DLog.LogWarningFormat("暂不支持的类型,无法存储对应的数据.object = {0} , Type ={1}", pObject, pType);
                break;
            }
        }