当前位置: 首页>>代码示例>>C#>>正文


C# BitReader.ReadUInt64方法代码示例

本文整理汇总了C#中BitReader.ReadUInt64方法的典型用法代码示例。如果您正苦于以下问题:C# BitReader.ReadUInt64方法的具体用法?C# BitReader.ReadUInt64怎么用?C# BitReader.ReadUInt64使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BitReader的用法示例。


在下文中一共展示了BitReader.ReadUInt64方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DoDeserializeFromByteArray

        /// <summary>
        /// This method is used to deserialize the Compact64bitInt 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 Compact64bitInt basic object.</returns>
        protected override int DoDeserializeFromByteArray(byte[] byteArray, int startIndex) // return the length consumed
        {
            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 0:
                        this.DecodedValue = bitReader.ReadUInt64(7);
                        this.Type = CompactUint7bitType;
                        return 1;

                    case 1:
                        this.DecodedValue = bitReader.ReadUInt64(14);
                        this.Type = CompactUint14bitType;
                        return 2;

                    case 2:
                        this.DecodedValue = bitReader.ReadUInt64(21);
                        this.Type = CompactUint21bitType;
                        return 3;

                    case 3:
                        this.DecodedValue = bitReader.ReadUInt64(28);
                        this.Type = CompactUint28bitType;
                        return 4;

                    case 4:
                        this.DecodedValue = bitReader.ReadUInt64(35);
                        this.Type = CompactUint35bitType;
                        return 5;

                    case 5:
                        this.DecodedValue = bitReader.ReadUInt64(42);
                        this.Type = CompactUint42bitType;
                        return 6;

                    case 6:
                        this.DecodedValue = bitReader.ReadUInt64(49);
                        this.Type = CompactUint49bitType;
                        return 7;

                    case 7:
                        this.DecodedValue = bitReader.ReadUInt64(64);
                        this.Type = CompactUint64bitType;
                        return 9;

                    case 8:
                        this.DecodedValue = 0;
                        this.Type = CompactUintNullType;
                        return 1;

                    default:
                        throw new InvalidOperationException("Failed to parse the Compact64bitInt, the type value is unexpected");
                }
            }
        }
开发者ID:ClareMSYanGit,项目名称:Interop-TestSuites,代码行数:75,代码来源:Compact64bitInt.cs

示例2: GetCompressedSize

 /// <summary>
 /// This method is used to get the compressed size value from the data file signature.
 /// </summary>
 /// <param name="dataFileSignature">Specify the signature of the zip file content.</param>
 /// <returns>Return the compressed size value.</returns>
 private ulong GetCompressedSize(byte[] dataFileSignature)
 {
     using (BitReader reader = new BitReader(dataFileSignature, 0))
     {
         reader.ReadUInt32(32);
         return reader.ReadUInt64(64);
     }
 }
开发者ID:OfficeDev,项目名称:Interop-TestSuites,代码行数:13,代码来源:ZipFilesChunking.cs


注:本文中的BitReader.ReadUInt64方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。