public void Serialize() { object obj = new java.lang.Long(long.MaxValue); byte[] bytes = SqlObject.Serialize(obj); Assert.That(!SqlObject.StartsWithSerializationHeader(bytes)); SqlObject wrapper = new SqlObject(bytes, true); object wrappedObject = wrapper.getObject(); Assert.AreEqual(new java.lang.Long(long.MaxValue), wrappedObject); bytes = SqlObject.Serialize(long.MaxValue); Assert.That(SqlObject.StartsWithSerializationHeader(bytes)); bool isJavaObject; obj = SqlObject.Deserialize(bytes, out isJavaObject); Assert.IsFalse(isJavaObject); Assert.AreEqual(long.MaxValue, obj); wrapper = new SqlObject(bytes); obj = wrapper.getObject(); Assert.AreEqual(long.MaxValue, obj); }
public void Deserialize() { MemoryStream stream = new MemoryStream(); (new BinaryFormatter()).Serialize(stream, 12345.6789D); byte[] bytes = SqlObject.AddSerializationHeader(stream.ToArray()); bool isJavaObject = true; object obj = SqlObject.Deserialize(bytes, out isJavaObject); Assert.IsFalse(isJavaObject); Assert.AreEqual(12345.6789D, obj); Assert.IsInstanceOfType(typeof(double), obj); }
/// <summary> /// For the current row, gets an instance of the provider-specific /// representation of the value of the field with the given column /// ordinal. /// </summary> /// <remarks> /// Because this method does not check if this reader /// is open or if row data is available, it should be invoked /// *only* when it is already known that this reader is open and /// row data is available. /// </remarks> /// <param name="ordinal">The column ordinal.</param> /// <returns>The provider-specific value representation.</returns> internal object GetProviderSpecificValueInternal(int ordinal) { object value = m_currentRecord.data[ordinal]; if (value == null) { return(null); } int type = m_metaData.colTypes[ordinal]; switch (type) { case (int)HsqlProviderType.Array: { return(value); } case (int)HsqlProviderType.BigInt: { return(value); } case (int)HsqlProviderType.Binary: { return(((org.hsqldb.types.Binary)value).getClonedBytes()); } case (int)HsqlProviderType.Blob: { return(value); } case (int)HsqlProviderType.Boolean: { return(value); } case (int)HsqlProviderType.Char: { return(value); } case (int)HsqlProviderType.Clob: { return(value); } case (int)HsqlProviderType.DataLink: { return(value); } case (int)HsqlProviderType.Date: { return((java.sql.Date)((java.sql.Date)value).clone()); } case (int)HsqlProviderType.Decimal: { return(value); } case (int)HsqlProviderType.Distinct: { return(value); } case (int)HsqlProviderType.Double: { return(value); } case (int)HsqlProviderType.Float: { return(value); } case (int)HsqlProviderType.Integer: { return(value); } case (int)HsqlProviderType.JavaObject: { return(value); } case (int)HsqlProviderType.LongVarBinary: { return(((org.hsqldb.types.Binary)value).getClonedBytes()); } case (int)HsqlProviderType.LongVarChar: { return(value); } case (int)HsqlProviderType.Null: { return(null); } case (int)HsqlProviderType.Numeric: { return(value); } case (int)HsqlProviderType.Object: { byte[] bytes = ((org.hsqldb.types.JavaObject)value).getBytes(); bool isJavaObject; return(SqlObject.Deserialize(bytes, out isJavaObject)); } case (int)HsqlProviderType.Real: { return(value); } case (int)HsqlProviderType.Ref: { return(value); } case (int)HsqlProviderType.SmallInt: { return(value); } case (int)HsqlProviderType.Struct: { return(value); } case (int)HsqlProviderType.Time: { return((java.sql.Time)((java.sql.Time)value).clone()); } case (int)HsqlProviderType.TimeStamp: { return((java.sql.Timestamp)((java.sql.Timestamp)value).clone()); } case (int)HsqlProviderType.TinyInt: { return(value); } case (int)HsqlProviderType.VarBinary: { byte[] bytes = ((org.hsqldb.types.Binary)value).getClonedBytes(); return(new org.hsqldb.types.Binary(bytes, false)); } case (int)HsqlProviderType.VarChar: { return(value); } case (int)HsqlProviderType.Xml: { return(value); } default: { throw HsqlConvert.UnknownConversion(value, type); } } }