本文整理汇总了C#中Microsoft.Cci.BlobBuilder.WriteUInt16BE方法的典型用法代码示例。如果您正苦于以下问题:C# BlobBuilder.WriteUInt16BE方法的具体用法?C# BlobBuilder.WriteUInt16BE怎么用?C# BlobBuilder.WriteUInt16BE使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Cci.BlobBuilder
的用法示例。
在下文中一共展示了BlobBuilder.WriteUInt16BE方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteCompressedInteger
internal static void WriteCompressedInteger(BlobBuilder writer, uint value)
{
unchecked
{
if (value <= SingleByteCompressedIntegerMaxValue)
{
writer.WriteByte((byte)value);
}
else if (value <= TwoByteCompressedIntegerMaxValue)
{
writer.WriteUInt16BE((ushort)(0x8000 | value));
}
else if (value <= MaxCompressedIntegerValue)
{
writer.WriteUInt32BE(0xc0000000 | value);
}
else
{
ThrowValueArgumentOutOfRange();
}
}
}
示例2: WriteCompressedSignedInteger
internal static void WriteCompressedSignedInteger(BlobBuilder writer, int value)
{
unchecked
{
const int b6 = (1 << 6) - 1;
const int b13 = (1 << 13) - 1;
const int b28 = (1 << 28) - 1;
// 0xffffffff for negative value
// 0x00000000 for non-negative
int signMask = value >> 31;
if ((value & ~b6) == (signMask & ~b6))
{
int n = ((value & b6) << 1) | (signMask & 1);
writer.WriteByte((byte)n);
}
else if ((value & ~b13) == (signMask & ~b13))
{
int n = ((value & b13) << 1) | (signMask & 1);
writer.WriteUInt16BE((ushort)(0x8000 | n));
}
else if ((value & ~b28) == (signMask & ~b28))
{
int n = ((value & b28) << 1) | (signMask & 1);
writer.WriteUInt32BE(0xc0000000 | (uint)n);
}
else
{
ThrowValueArgumentOutOfRange();
}
}
}