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


C# BitWriter.AppendInit32方法代码示例

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


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

示例1: SerializeToByteList

        /// <summary>
        /// This method is used to convert the element into a byte List 
        /// </summary>
        /// <returns>Return the Byte List</returns>
        public override List<byte> SerializeToByteList()
        {
            // Storage Index Extended GUID
            this.StorageIndexExtendedGUID = this.StorageIndexExtendedGUID ?? new ExGuid();
            List<byte> storageIndexExtendedGUIDBytes = this.StorageIndexExtendedGUID.SerializeToByteList();

            // Expect Storage Index Extended GUID
            List<byte> expectedStorageIndexExtendedGUIDBytes = this.ExpectedStorageIndexExtendedGUID.SerializeToByteList();
            
            // Put Changes Request
            this.PutChangesRequestStart = new StreamObjectHeaderStart32bit(StreamObjectTypeHeaderStart.PutChangesRequest, 1 + storageIndexExtendedGUIDBytes.Count + expectedStorageIndexExtendedGUIDBytes.Count);
            List<byte> putChangesRequestBytes = this.PutChangesRequestStart.SerializeToByteList();
            
            // reserved
            BitWriter bitWriter = new BitWriter(1);
            bitWriter.AppendInit32(this.ImplyNullExpectedIfNoMapping, 1);
            bitWriter.AppendInit32(this.Partial, 1);
            bitWriter.AppendInit32(this.PartialLast, 1);
            bitWriter.AppendInit32(this.FavorCoherencyFailureOverNotFound, 1);
            bitWriter.AppendInit32(this.AbortRemainingPutChangesOnFailure, 1);
            bitWriter.AppendInit32(this.MultiRequestPutHint, 1);
            bitWriter.AppendInit32(this.ReturnCompleteKnowledgeIfPossible, 1);
            bitWriter.AppendInit32(this.LastWriterWinsOnNextChange, 1);

            List<byte> reservedBytes = new List<byte>(bitWriter.Bytes);

            List<byte> byteList = new List<byte>();
            
            // sub-request start
            byteList.AddRange(base.SerializeToByteList());
            
            // put change request
            byteList.AddRange(putChangesRequestBytes);
            
            // Storage Index Extended GUID
            byteList.AddRange(storageIndexExtendedGUIDBytes);

            // Expected Storage Index Extended GUID
            byteList.AddRange(expectedStorageIndexExtendedGUIDBytes);
            
            // reserved
            byteList.AddRange(reservedBytes);

            if (this.IsAdditionalFlagsUsed)
            {
                this.AdditionalFlagsStart = new StreamObjectHeaderStart32bit(StreamObjectTypeHeaderStart.AdditionalFlags, 2);
                byteList.AddRange(this.AdditionalFlagsStart.SerializeToByteList());

                BitWriter additionalFlagsWriter = new BitWriter(2);
                additionalFlagsWriter.AppendInit32(this.ReturnAppliedStorageIndexIdEntries, 1);
                additionalFlagsWriter.AppendInit32(this.ReturnDataElementsAdded, 1);
                additionalFlagsWriter.AppendInit32(this.CheckForIdReuse, 1);
                additionalFlagsWriter.AppendInit32(this.CoherencyCheckOnlyAppliedIndexEntries, 1);
                additionalFlagsWriter.AppendInit32(this.FullFileReplacePut, 1);
                additionalFlagsWriter.AppendInit32(this.Reserve, 11);
                byteList.AddRange(additionalFlagsWriter.Bytes);
            }

            if (this.IsLockIdUsed)
            {
                this.LockIdStart = new StreamObjectHeaderStart32bit(StreamObjectTypeHeaderStart.PutChangesLockId, 16);
                byteList.AddRange(this.LockIdStart.SerializeToByteList());
                byteList.AddRange(this.LockID.ToByteArray());
            }

            if (this.OptionalClientKnowledge != null)
            {
                byteList.AddRange(this.OptionalClientKnowledge.SerializeToByteList());
            }

            // sub-request end
            byteList.AddRange(this.ToBytesEnd());

            return byteList;
        }
开发者ID:ClareMSYanGit,项目名称:Interop-TestSuites,代码行数:79,代码来源:PutChangesCellSubRequest.cs

示例2: SerializeToByteList

        /// <summary>
        /// This method is used to convert the element into a byte List 
        /// </summary>
        /// <returns>Return the Byte List</returns>
        public override List<byte> SerializeToByteList()
        {
            List<byte> byteList = new List<byte>();
            byteList.AddRange(base.SerializeToByteList());
            
            // Query Changes Request 
            byteList.AddRange(this.QueryChangesRequest.SerializeToByteList());
            
            // Reserved1
            BitWriter bitWriter = new BitWriter(1);
            bitWriter.AppendInit32(this.Reserved, 1);
            bitWriter.AppendInit32(this.AllowFragments, 1);
            bitWriter.AppendInit32(this.ExcludeObjectData, 1);
            bitWriter.AppendInit32(this.IncludeFilteredOutDataElementsInKnowledge, 1);
            bitWriter.AppendInit32(this.Reserved1, 4);
            byteList.AddRange(bitWriter.Bytes);

            // Cell ID bytes
            List<byte> cellIDBytes = this.CellId.SerializeToByteList();

            // Query Changes Request Arguments 
            this.QueryChangesRequestArguments = new StreamObjectHeaderStart32bit(StreamObjectTypeHeaderStart.QueryChangesRequestArguments, 1 + cellIDBytes.Count);
            byteList.AddRange(this.QueryChangesRequestArguments.SerializeToByteList());

            // Reserved2
            bitWriter = new BitWriter(1);
            bitWriter.AppendInit32(this.IncludeStorageManifest, 1);
            bitWriter.AppendInit32(this.IncludeCellChanges, 1);
            bitWriter.AppendInit32(this.Reserved2, 6);
            byteList.AddRange(bitWriter.Bytes);

            // Cell ID
            byteList.AddRange(cellIDBytes);

            // optional
            if (this.MaxDataElements != null)
            {
                if (this.MaxDataElements.DecodedValue > 0)
                {
                    // Max Data Elements bytes
                    List<byte> maxDataElementsBytes = (new Compact64bitInt(this.MaxDataElements.DecodedValue)).SerializeToByteList();
                    
                    // Query Changes Data Constraints 
                    this.QueryChangesDataConstraints = new StreamObjectHeaderStart32bit(StreamObjectTypeHeaderStart.QueryChangesDataConstraint, maxDataElementsBytes.Count);
                    byteList.AddRange(this.QueryChangesDataConstraints.SerializeToByteList());
                    
                    // Max Data Elements
                    byteList.AddRange(maxDataElementsBytes);
                }
            }

            if (this.QueryChangeFilters != null)
            {
                foreach (Filter filter in this.QueryChangeFilters)
                {
                    byteList.AddRange(filter.SerializeToByteList());
                }
            }

            if (this.Knowledge != null)
            {
                byteList.AddRange(this.Knowledge.SerializeToByteList());
            }

            byteList.AddRange(this.ToBytesEnd());
            return byteList;
        }
开发者ID:OfficeDev,项目名称:Interop-TestSuites,代码行数:71,代码来源:QueryChangesCellSubRequest.cs

示例3: SerializeToByteList

 /// <summary>
 /// This method is used to convert the element of StreamObjectHeaderEnd16bit basic object into a byte List.
 /// </summary>
 /// <returns>Return the byte list which store the byte information of StreamObjectHeaderEnd16bit.</returns>
 public override List<byte> SerializeToByteList()
 {
     BitWriter bitFieldWriter = new BitWriter(2);
     bitFieldWriter.AppendInit32(0x3, 2);
     bitFieldWriter.AppendUInit32(Convert.ToUInt32(this.Type), 14);
     return new List<byte>(bitFieldWriter.Bytes);
 }
开发者ID:OfficeDev,项目名称:Interop-TestSuites,代码行数:11,代码来源:StreamObjectHeader.cs

示例4: 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

示例5: SerializeToByteList

        /// <summary>
        /// This method is used to convert the element into a byte List 
        /// </summary>
        /// <returns>Return the Byte List</returns>
        public List<byte> SerializeToByteList()
        {
            this.RequestStart = new StreamObjectHeaderStart32bit(StreamObjectTypeHeaderStart.Request, 0);
            this.UserAgentStart = new StreamObjectHeaderStart32bit(StreamObjectTypeHeaderStart.UserAgent, 0);
            this.UserAgentGUID = new StreamObjectHeaderStart32bit(StreamObjectTypeHeaderStart.UserAgentGUID, 16);
            this.UserAgentVersion = new StreamObjectHeaderStart32bit(StreamObjectTypeHeaderStart.UserAgentversion, 4);
            this.UserAgentEnd = new StreamObjectHeaderEnd16bit((int)StreamObjectTypeHeaderEnd.UserAgent);
            this.CellRequestEnd = new StreamObjectHeaderEnd16bit((int)StreamObjectTypeHeaderEnd.Request);
            
            List<byte> byteList = new List<byte>();

            // Protocol Version
            byteList.AddRange(LittleEndianBitConverter.GetBytes(this.ProtocolVersion));

            // Minimum Version
            byteList.AddRange(LittleEndianBitConverter.GetBytes(this.MinimumVersion));

            // Signature
            byteList.AddRange(LittleEndianBitConverter.GetBytes(this.Signature));

            // Request Start
            byteList.AddRange(this.RequestStart.SerializeToByteList());

            // User Agent Start
            byteList.AddRange(this.UserAgentStart.SerializeToByteList());

            // User Agent GUID
            byteList.AddRange(this.UserAgentGUID.SerializeToByteList());

            // GUID
            byteList.AddRange(this.GUID.ToByteArray());

            // User Agent Version
            byteList.AddRange(this.UserAgentVersion.SerializeToByteList());

            // Version
            byteList.AddRange(LittleEndianBitConverter.GetBytes(this.Version));

            // User Agent End
            byteList.AddRange(this.UserAgentEnd.SerializeToByteList());

            if (this.IsRequestHashingOptionsUsed)
            {
                List<byte> hashSchemaList = this.RequestHashingSchema.SerializeToByteList();
                this.RequestHashingOptionsDeclaration = new StreamObjectHeaderStart32bit(StreamObjectTypeHeaderStart.RequestHashOptions, hashSchemaList.Count + 1);

                // Request Hashing Options Declaration
                byteList.AddRange(this.RequestHashingOptionsDeclaration.SerializeToByteList());

                // Request Hashing Schema
                byteList.AddRange(hashSchemaList);

                // Reserve
                BitWriter bw = new BitWriter(1);
                bw.AppendInit32(this.Reserve1, 1);
                bw.AppendInit32(this.Reserve2, 1);
                bw.AppendInit32(this.RequestDataElementHashesInsteadofData, 1);
                bw.AppendInit32(this.RequestDataElementHashes, 1);
                bw.AppendInit32(this.Reserve3, 4);
                byteList.AddRange(bw.Bytes);
            }

            // Sub-requests
            if (this.SubRequests != null && this.SubRequests.Count != 0)
            {
                foreach (FsshttpbCellSubRequest subRequest in this.SubRequests)
                {
                    byteList.AddRange(subRequest.SerializeToByteList());
                }
            }
            else
            {
                throw new InvalidOperationException("MUST contain sub request in request structure which is defined in the MS-FSSHTTPB.");
            }

            // Data Element Package 
            if (this.DataElementPackage != null)
            {
                byteList.AddRange(this.DataElementPackage.SerializeToByteList());
            }

            // Cell Request End 
            byteList.AddRange(this.CellRequestEnd.SerializeToByteList());

            return byteList;
        }
开发者ID:ClareMSYanGit,项目名称:Interop-TestSuites,代码行数:90,代码来源:FsshttpbCellRequest.cs


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