本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
}
}
示例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);
}
示例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);
}
示例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]);
}
}