Exemplo n.º 1
0
        public object readValue(int offset, AA2DataType type, int length = 0)
        {
            switch (type)
            {
                case AA2DataType.Bool:
                    if (raw[offset] == 0)
                        return false;
                    else
                        return true;
                case AA2DataType.Byte:
                    return raw[offset];
                case AA2DataType.String:
                    byte[] b = new byte[length];
                    for (int i = 0; i < length; i++)
                        b[i] = raw[offset + i];
                    return Tools.ShiftJIS.GetString(b);
                case AA2DataType.StringEx:
                    byte[] bx = new byte[length];
                    for (int i = 0; i < length; i++)
                        bx[i] = raw[offset + i];
                    return Tools.ShiftJIS.GetString(Tools.ExTransform(bx));
                case AA2DataType.DataBlock:
                    var block = new byte[length];
                    Array.Copy(raw, offset, block, 0, length);
                    return new BaseData(block);
                default:
#warning finish implementation
                    throw new NotImplementedException();
            }
        }
Exemplo n.º 2
0
        public void writeValue(object value, int offset, AA2DataType type)
        {
            switch (type)
            {
                case AA2DataType.Bool:
                    if ((bool)value)
                        raw[offset] = 1;
                    else
                        raw[offset] = 0;
                    break;
                case AA2DataType.Byte:
                    raw[offset] = (byte)value;
                    break;
                case AA2DataType.String:
                    byte[] b = Tools.ShiftJIS.GetBytes((string)value);
                    for (int i = 0; i < b.Length; i++)
                        raw[offset + i] = b[i];
                    break;
                case AA2DataType.StringEx:
                    byte[] bx = Tools.ExTransform(Tools.ShiftJIS.GetBytes((string)value));
                    for (int i = 0; i < bx.Length; i++)
                        raw[offset + i] = bx[i];
                    break;
                case AA2DataType.DataBlock:
                    var block = (BaseData)value;
                    Array.Copy(block, 0, this.raw, offset, block.dataLength);
                    break;
                default:
#warning finish implementation
                    throw new NotImplementedException();
            }
        }
Exemplo n.º 3
0
        public void writeValue(object value, int offset, AA2DataType type)
        {
            switch (type)
            {
            case AA2DataType.Bool:
                if ((bool)value)
                {
                    raw[offset] = 1;
                }
                else
                {
                    raw[offset] = 0;
                }
                break;

            case AA2DataType.Byte:
                raw[offset] = (byte)value;
                break;

            case AA2DataType.String:
                byte[] b = Tools.ShiftJIS.GetBytes((string)value);
                for (int i = 0; i < b.Length; i++)
                {
                    raw[offset + i] = b[i];
                }
                break;

            case AA2DataType.StringEx:
                byte[] bx = Tools.ExTransform(Tools.ShiftJIS.GetBytes((string)value));
                for (int i = 0; i < bx.Length; i++)
                {
                    raw[offset + i] = bx[i];
                }
                break;

            case AA2DataType.DataBlock:
                var block = (BaseData)value;
                Array.Copy(block.raw, 0, this.raw, offset, block.dataLength);
                break;

            default:
#warning finish implementation
                throw new NotImplementedException();
            }
        }
Exemplo n.º 4
0
        public object readValue(int offset, AA2DataType type, int length = 0)
        {
            switch (type)
            {
            case AA2DataType.Bool:
                if (raw[offset] == 0)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }

            case AA2DataType.Byte:
                return(raw[offset]);

            case AA2DataType.String:
                byte[] b = new byte[length];
                for (int i = 0; i < length; i++)
                {
                    b[i] = raw[offset + i];
                }
                return(Tools.ShiftJIS.GetString(b));

            case AA2DataType.StringEx:
                byte[] bx = new byte[length];
                for (int i = 0; i < length; i++)
                {
                    bx[i] = raw[offset + i];
                }
                return(Tools.ShiftJIS.GetString(Tools.ExTransform(bx)));

            case AA2DataType.DataBlock:
                var block = new byte[length];
                Array.Copy(raw, offset, block, 0, length);
                return(new BaseData(block));

            default:
#warning finish implementation
                throw new NotImplementedException();
            }
        }