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


C# BitWriter.AppendUInt64方法代码示例

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


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

示例1: SerializeToByteList

        /// <summary>
        /// This method is used to convert the element of Compact64bitInt basic object into a byte List.
        /// </summary>
        /// <returns>Return the byte list which store the byte information of Compact64bitInt.</returns>
        public override List<byte> SerializeToByteList()
        {
            BitWriter bitWriter = new BitWriter(9);

            if (this.DecodedValue == 0)
            {
                bitWriter.AppendUInt64(0, 8);
            }
            else if (this.DecodedValue >= 0x01 && this.DecodedValue <= 0x7F)
            {
                bitWriter.AppendUInt64(CompactUint7bitType, 1);
                bitWriter.AppendUInt64(this.DecodedValue, 7);
            }
            else if (this.DecodedValue >= 0x0080 && this.DecodedValue <= 0x3FFF)
            {
                bitWriter.AppendUInt64(CompactUint14bitType, 2);
                bitWriter.AppendUInt64(this.DecodedValue, 14);
            }
            else if (this.DecodedValue >= 0x004000 && this.DecodedValue <= 0x1FFFFF)
            {
                bitWriter.AppendUInt64(CompactUint21bitType, 3);
                bitWriter.AppendUInt64(this.DecodedValue, 21);
            }
            else if (this.DecodedValue >= 0x0200000 && this.DecodedValue <= 0xFFFFFFF)
            {
                bitWriter.AppendUInt64(CompactUint28bitType, 4);
                bitWriter.AppendUInt64(this.DecodedValue, 28);
            }
            else if (this.DecodedValue >= 0x010000000 && this.DecodedValue <= 0x7FFFFFFFF)
            {
                bitWriter.AppendUInt64(CompactUint35bitType, 5);
                bitWriter.AppendUInt64(this.DecodedValue, 35);
            }
            else if (this.DecodedValue >= 0x00800000000 && this.DecodedValue <= 0x3FFFFFFFFFF)
            {
                bitWriter.AppendUInt64(CompactUint42bitType, 6);
                bitWriter.AppendUInt64(this.DecodedValue, 42);
            }
            else if (this.DecodedValue >= 0x0040000000000 && this.DecodedValue <= 0x1FFFFFFFFFFFF)
            {
                bitWriter.AppendUInt64(CompactUint49bitType, 7);
                bitWriter.AppendUInt64(this.DecodedValue, 49);
            }
            else if (this.DecodedValue >= 0x0002000000000000 && this.DecodedValue <= 0xFFFFFFFFFFFFFFFF)
            {
                bitWriter.AppendUInt64(CompactUint64bitType, 8);
                bitWriter.AppendUInt64(this.DecodedValue, 64);
            }

            return new List<byte>(bitWriter.Bytes);
        }
开发者ID:ClareMSYanGit,项目名称:Interop-TestSuites,代码行数:55,代码来源:Compact64bitInt.cs

示例2: AnalyzeFileHeader

        /// <summary>
        /// This method is used to analyze the zip file header.
        /// </summary>
        /// <param name="content">Specify the zip content.</param>
        /// <param name="index">Specify the start position.</param>
        /// <param name="dataFileSignature">Specify the output value for the data file signature.</param>
        /// <returns>Return the data file content.</returns>
        private byte[] AnalyzeFileHeader(byte[] content, int index, out byte[] dataFileSignature)
        {
            int crc32 = BitConverter.ToInt32(content, index + 14);
            int compressedSize = BitConverter.ToInt32(content, index + 18);
            int uncompressedSize = BitConverter.ToInt32(content, index + 22);
            int fileNameLength = BitConverter.ToInt16(content, index + 26);
            int extraFileldLength = BitConverter.ToInt16(content, index + 28);
            int headerLength = 30 + fileNameLength + extraFileldLength;

            BitWriter writer = new BitWriter(20);
            writer.AppendInit32(crc32, 32);
            writer.AppendUInt64((ulong)compressedSize, 64);
            writer.AppendUInt64((ulong)uncompressedSize, 64);
            dataFileSignature = writer.Bytes;

            return AdapterHelper.GetBytes(content, index, headerLength);
        }
开发者ID:OfficeDev,项目名称:Interop-TestSuites,代码行数:24,代码来源:ZipFilesChunking.cs


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