當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。