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


C# ObjectWriter.WriteByte方法代码示例

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


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

示例1: SerializeChecksumWithChildren

        public void SerializeChecksumWithChildren(ChecksumWithChildren checksums, ObjectWriter writer, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var kind = checksums.GetWellKnownSynchronizationKind();
            writer.WriteString(kind);
            checksums.Checksum.WriteTo(writer);

            writer.WriteInt32(checksums.Children.Count);
            foreach (var child in checksums.Children)
            {
                var checksum = child as Checksum;
                if (checksum != null)
                {
                    writer.WriteByte(ChecksumKind);
                    checksum.WriteTo(writer);
                    continue;
                }

                var checksumCollection = child as ChecksumCollection;
                if (checksumCollection != null)
                {
                    writer.WriteByte(ChecksumWithChildrenKind);
                    SerializeChecksumWithChildren(checksumCollection, writer, cancellationToken);
                    continue;
                }

                throw ExceptionUtilities.UnexpectedValue(child);
            }
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:30,代码来源:Serializer_ChecksumWithChildren.cs

示例2: SerializeChecksumObjectWithChildrenAsync

        public async Task SerializeChecksumObjectWithChildrenAsync(ChecksumObjectWithChildren checksumObject, ObjectWriter writer, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            writer.WriteString(checksumObject.Kind);
            checksumObject.Checksum.WriteTo(writer);

            writer.WriteInt32(checksumObject.Children.Length);
            foreach (var child in checksumObject.Children)
            {
                var checksum = child as Checksum;
                if (checksum != null)
                {
                    writer.WriteByte(ChecksumKind);
                    checksum.WriteTo(writer);
                    continue;
                }

                var checksumCollection = child as ChecksumCollection;
                if (checksumCollection != null)
                {
                    writer.WriteByte(ChecksumCollectionKind);
                    await SerializeChecksumObjectWithChildrenAsync(checksumCollection, writer, cancellationToken).ConfigureAwait(false);
                    continue;
                }

                throw ExceptionUtilities.UnexpectedValue(child);
            }
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:29,代码来源:Serializer_ChecksumObjectWithChildren.cs

示例3: WriteBitArray

        private static void WriteBitArray(ObjectWriter writer, BitArray bitArray)
        {
            // Our serialization format doesn't round-trip bit arrays of non-byte lengths
            Contract.ThrowIfTrue(bitArray.Length % 8 != 0);

            writer.WriteInt32(bitArray.Length / 8);

            // This will hold the byte that we will write out after we process every 8 bits. This is
            // LSB, so we push bits into it from the MSB.
            byte b = 0;

            for (var i = 0; i < bitArray.Length; i++)
            {
                if (bitArray[i])
                {
                    b = (byte)(0x80 | b >> 1);
                }
                else
                {
                    b >>= 1;
                }

                if ((i + 1) % 8 == 0)
                {
                    // End of a byte, write out the byte
                    writer.WriteByte(b);
                }
            }
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:29,代码来源:BloomFilter_Serialization.cs

示例4: WriteTo

            public override void WriteTo(Encoding encoding, ObjectWriter writer, CancellationToken cancellationToken)
            {
                if (encoding == null)
                {
                    base.WriteTo(encoding, writer, cancellationToken);
                    return;
                }

                cancellationToken.ThrowIfCancellationRequested();

                writer.WriteByte(EncodingSerialization);

                byte[] value;
                if (!s_encodingCache.TryGetValue(encoding, out value))
                {
                    // we don't have cache, cache it
                    var formatter = new BinaryFormatter();
                    using (var stream = SerializableBytes.CreateWritableStream())
                    {
                        // unfortunately, this is only way to properly clone encoding
                        formatter.Serialize(stream, encoding);
                        value = stream.ToArray();

                        // add if not already exist. otherwise, noop
                        s_encodingCache.TryAdd(encoding, value);
                    }
                }

                // write data out
                writer.WriteValue(value);
            }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:31,代码来源:DesktopReferenceSerializationServiceFactory.cs

示例5: WriteTo

 internal void WriteTo(ObjectWriter writer)
 {
     writer.WriteString(Name);
     writer.WriteString(ContainerDisplayName);
     writer.WriteString(FullyQualifiedContainerName);
     writer.WriteByte((byte)Kind);
     writer.WriteInt32(Span.Start);
     writer.WriteInt32(Span.Length);
     writer.WriteUInt16(ParameterCount);
     writer.WriteUInt16(TypeParameterCount);
 }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:11,代码来源:DeclaredSymbolInfo.cs

示例6: WriteTo

        public static void WriteTo(this BitArray bitArray, ObjectWriter writer)
        {
            // TODO : think about a way to use pool for byte array.
            // BitArray will internally allocate another int array. probably need to drop BitArray usage.
            var bytes = new byte[(bitArray.Length + 7) / 8];
            bitArray.CopyTo(bytes, 0);

            writer.WriteString(SerializationFormat);
            writer.WriteInt32(bytes.Length);

            for (var i = 0; i < bytes.Length; i++)
            {
                writer.WriteByte(bytes[i]);
            }
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:15,代码来源:BitArrayUtilities.cs


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