本文整理汇总了C#中BitReader.ReadGuid方法的典型用法代码示例。如果您正苦于以下问题:C# BitReader.ReadGuid方法的具体用法?C# BitReader.ReadGuid怎么用?C# BitReader.ReadGuid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitReader
的用法示例。
在下文中一共展示了BitReader.ReadGuid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoDeserializeFromByteArray
/// <summary>
/// This method is used to deserialize the ExGuid basic object from the specified byte array and start index.
/// </summary>
/// <param name="byteArray">Specify the byte array.</param>
/// <param name="startIndex">Specify the start index from the byte array.</param>
/// <returns>Return the length in byte of the ExGuid basic object.</returns>
protected override int DoDeserializeFromByteArray(byte[] byteArray, int startIndex)
{
using (BitReader bitReader = new BitReader(byteArray, startIndex))
{
int numberOfContinousZeroBit = 0;
while (numberOfContinousZeroBit < 8 && bitReader.MoveNext())
{
if (bitReader.Current == false)
{
numberOfContinousZeroBit++;
}
else
{
break;
}
}
switch (numberOfContinousZeroBit)
{
case 2:
this.Value = bitReader.ReadUInt32(5);
this.GUID = bitReader.ReadGuid();
this.Type = ExtendedGUID5BitUintType;
return 17;
case 5:
this.Value = bitReader.ReadUInt32(10);
this.GUID = bitReader.ReadGuid();
this.Type = ExtendedGUID10BitUintType;
return 18;
case 6:
this.Value = bitReader.ReadUInt32(17);
this.GUID = bitReader.ReadGuid();
this.Type = ExtendedGUID17BitUintType;
return 19;
case 7:
this.Value = bitReader.ReadUInt32(32);
this.GUID = bitReader.ReadGuid();
this.Type = ExtendedGUID32BitUintType;
return 21;
case 8:
this.GUID = Guid.Empty;
this.Type = ExtendedGUIDNullType;
return 1;
default:
throw new InvalidOperationException("Failed to parse the ExGuid, the type value is unexpected");
}
}
}