public static IResponse ProcessOperation(int operation, IXdrReader xdr) { switch (operation) { case IscCodes.op_response: return(new GenericResponse( xdr.ReadInt32(), xdr.ReadInt64(), xdr.ReadBuffer(), xdr.ReadStatusVector())); case IscCodes.op_fetch_response: return(new FetchResponse(xdr.ReadInt32(), xdr.ReadInt32())); case IscCodes.op_sql_response: return(new SqlResponse(xdr.ReadInt32())); case IscCodes.op_trusted_auth: return(new AuthResponse(xdr.ReadBuffer())); case IscCodes.op_crypt_key_callback: return(new CryptKeyCallbackResponse(xdr.ReadBuffer())); default: throw new ArgumentOutOfRangeException(nameof(operation), $"{nameof(operation)}={operation}"); } }
protected async Task <object> ReadRawValue(IXdrReader xdr, DbField field, AsyncWrappingCommonArgs async) { var innerCharset = !_database.Charset.IsNoneCharset ? _database.Charset : field.Charset; switch (field.DbDataType) { case DbDataType.Char: if (field.Charset.IsOctetsCharset) { return(await xdr.ReadOpaque(field.Length, async).ConfigureAwait(false)); } else { var s = await xdr.ReadString(innerCharset, field.Length, async).ConfigureAwait(false); if ((field.Length % field.Charset.BytesPerCharacter) == 0 && s.Length > field.CharCount) { return(s.Substring(0, field.CharCount)); } else { return(s); } } case DbDataType.VarChar: if (field.Charset.IsOctetsCharset) { return(await xdr.ReadBuffer(async).ConfigureAwait(false)); } else { return(await xdr.ReadString(innerCharset, async).ConfigureAwait(false)); } case DbDataType.SmallInt: return(await xdr.ReadInt16(async).ConfigureAwait(false)); case DbDataType.Integer: return(await xdr.ReadInt32(async).ConfigureAwait(false)); case DbDataType.Array: case DbDataType.Binary: case DbDataType.Text: case DbDataType.BigInt: return(await xdr.ReadInt64(async).ConfigureAwait(false)); case DbDataType.Decimal: case DbDataType.Numeric: return(await xdr.ReadDecimal(field.DataType, field.NumericScale, async).ConfigureAwait(false)); case DbDataType.Float: return(await xdr.ReadSingle(async).ConfigureAwait(false)); case DbDataType.Guid: return(await xdr.ReadGuid(async).ConfigureAwait(false)); case DbDataType.Double: return(await xdr.ReadDouble(async).ConfigureAwait(false)); case DbDataType.Date: return(await xdr.ReadDate(async).ConfigureAwait(false)); case DbDataType.Time: return(await xdr.ReadTime(async).ConfigureAwait(false)); case DbDataType.TimeStamp: return(await xdr.ReadDateTime(async).ConfigureAwait(false)); case DbDataType.Boolean: return(await xdr.ReadBoolean(async).ConfigureAwait(false)); case DbDataType.TimeStampTZ: return(await xdr.ReadZonedDateTime(false, async).ConfigureAwait(false)); case DbDataType.TimeStampTZEx: return(await xdr.ReadZonedDateTime(true, async).ConfigureAwait(false)); case DbDataType.TimeTZ: return(await xdr.ReadZonedTime(false, async).ConfigureAwait(false)); case DbDataType.TimeTZEx: return(await xdr.ReadZonedTime(true, async).ConfigureAwait(false)); case DbDataType.Dec16: return(await xdr.ReadDec16(async).ConfigureAwait(false)); case DbDataType.Dec34: return(await xdr.ReadDec34(async).ConfigureAwait(false)); case DbDataType.Int128: return(await xdr.ReadInt128(async).ConfigureAwait(false)); default: throw TypeHelper.InvalidDataType((int)field.DbDataType); } }