本文整理汇总了C#中ISqlObject.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# ISqlObject.GetType方法的具体用法?C# ISqlObject.GetType怎么用?C# ISqlObject.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISqlObject
的用法示例。
在下文中一共展示了ISqlObject.GetType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ColumnSizeOf
internal override int ColumnSizeOf(ISqlObject obj)
{
if (obj is SqlNull || obj == null)
return 1;
if (!(obj is SqlNumber))
throw new ArgumentException(String.Format("Cannot determine the size of an object of type '{0}'.", obj.GetType()));
var number = (SqlNumber) obj;
if (number.IsNull)
return 1;
if (number.CanBeInt32)
return 1 + 4;
if (number.CanBeInt64)
return 1+ 8;
// Type + Scale + Precision + Byte Count
var length = number.ToByteArray().Length;
return 1 + 4 + 4 + 4 + length;
}
示例2: ColumnSizeOf
internal override int ColumnSizeOf(ISqlObject obj)
{
if (obj is SqlNull)
return 1;
if (!(obj is SqlDateTime))
throw new ArgumentException(String.Format("Cannot determine the size of an object of type '{0}'", obj.GetType()));
if (obj.IsNull)
return 1;
// Type + Length + Bytes
return 1 + 4 + 13;
}
示例3: SerializeObject
public override void SerializeObject(Stream stream, ISqlObject obj)
{
var writer = new BinaryWriter(stream);
if (obj.IsNull) {
if (TypeCode == SqlTypeCode.Clob ||
TypeCode == SqlTypeCode.LongVarChar) {
writer.Write((byte)3);
} else {
writer.Write((byte)1);
}
return;
}
var sqlString = (ISqlString)obj;
if (obj is SqlString) {
var bytes = ((SqlString) sqlString).ToByteArray(Encoding);
writer.Write((byte) 2);
writer.Write(bytes.Length);
writer.Write(bytes);
} else if (obj is SqlLongString) {
var longString = (SqlLongString) sqlString;
writer.Write((byte) 4);
writer.Write(longString.ObjectId.StoreId);
writer.Write(longString.ObjectId.Id);
} else {
throw new FormatException(String.Format("The object of type '{0}' is not handled by {1}", obj.GetType(), ToString()));
}
}