本文整理汇总了C#中System.Reflection.Metadata.BlobBuilder.WriteInt32方法的典型用法代码示例。如果您正苦于以下问题:C# BlobBuilder.WriteInt32方法的具体用法?C# BlobBuilder.WriteInt32怎么用?C# BlobBuilder.WriteInt32使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.Metadata.BlobBuilder
的用法示例。
在下文中一共展示了BlobBuilder.WriteInt32方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SerializeStandalonePdbStream
/// <summary>
/// Serialized #Pdb stream.
/// </summary>
protected override void SerializeStandalonePdbStream(BlobBuilder builder)
{
int startPosition = builder.Position;
// the id will be filled in later
_pdbIdBlob = builder.ReserveBytes(MetadataSizes.PdbIdSize);
builder.WriteInt32(_entryPoint.IsNil ? 0 : MetadataTokens.GetToken(_entryPoint));
builder.WriteUInt64(MetadataSizes.ExternalTablesMask);
MetadataWriterUtilities.SerializeRowCounts(builder, MetadataSizes.ExternalRowCounts);
int endPosition = builder.Position;
Debug.Assert(MetadataSizes.CalculateStandalonePdbStreamSize() == endPosition - startPosition);
}
示例2: Serialize
/// <summary>
/// Serialize the Debug Table and Data.
/// </summary>
/// <param name="builder">Builder.</param>
/// <param name="sectionLocation">The containing PE section location.</param>
/// <param name="sectionOffset">Offset of the table within the containing section.</param>
internal void Serialize(BlobBuilder builder, SectionLocation sectionLocation, int sectionOffset)
{
int dataOffset = sectionOffset + TableSize;
foreach (var entry in _entries)
{
int addressOfRawData;
int pointerToRawData;
if (entry.DataSize > 0)
{
addressOfRawData = sectionLocation.RelativeVirtualAddress + dataOffset;
pointerToRawData = sectionLocation.PointerToRawData + dataOffset;
}
else
{
addressOfRawData = 0;
pointerToRawData = 0;
}
builder.WriteUInt32(0); // characteristics, always 0
builder.WriteUInt32(entry.Stamp);
builder.WriteUInt32(entry.Version);
builder.WriteInt32((int)entry.Type);
builder.WriteInt32(entry.DataSize);
builder.WriteInt32(addressOfRawData);
builder.WriteInt32(pointerToRawData);
dataOffset += entry.DataSize;
}
builder.LinkSuffix(_dataBuilder);
}
示例3: WriteEmbeddedPortablePdbData
private static int WriteEmbeddedPortablePdbData(BlobBuilder builder, BlobBuilder debugMetadata)
{
int start = builder.Count;
// header (signature, decompressed size):
builder.WriteUInt32(PortablePdbVersions.DebugDirectoryEmbeddedSignature);
builder.WriteInt32(debugMetadata.Count);
// compressed data:
var compressed = new MemoryStream();
using (var deflate = new DeflateStream(compressed, CompressionLevel.Optimal, leaveOpen: true))
{
foreach (var blob in debugMetadata.GetBlobs())
{
var segment = blob.GetBytes();
deflate.Write(segment.Array, segment.Offset, segment.Count);
}
}
// TODO: avoid multiple copies:
builder.WriteBytes(compressed.ToArray());
return builder.Count - start;
}
示例4: WriteConstant
internal static void WriteConstant(BlobBuilder writer, object value)
{
if (value == null)
{
// The encoding of Type for the nullref value for FieldInit is ELEMENT_TYPE_CLASS with a Value of a 32-bit.
writer.WriteUInt32(0);
return;
}
var type = value.GetType();
if (type.GetTypeInfo().IsEnum)
{
type = Enum.GetUnderlyingType(type);
}
if (type == typeof(bool))
{
writer.WriteBoolean((bool)value);
}
else if (type == typeof(int))
{
writer.WriteInt32((int)value);
}
else if (type == typeof(string))
{
writer.WriteUTF16((string)value);
}
else if (type == typeof(byte))
{
writer.WriteByte((byte)value);
}
else if (type == typeof(char))
{
writer.WriteUInt16((char)value);
}
else if (type == typeof(double))
{
writer.WriteDouble((double)value);
}
else if (type == typeof(short))
{
writer.WriteInt16((short)value);
}
else if (type == typeof(long))
{
writer.WriteInt64((long)value);
}
else if (type == typeof(sbyte))
{
writer.WriteSByte((sbyte)value);
}
else if (type == typeof(float))
{
writer.WriteSingle((float)value);
}
else if (type == typeof(ushort))
{
writer.WriteUInt16((ushort)value);
}
else if (type == typeof(uint))
{
writer.WriteUInt32((uint)value);
}
else if (type == typeof(ulong))
{
writer.WriteUInt64((ulong)value);
}
else
{
throw new ArgumentException(SR.Format(SR.InvalidConstantValueOfType, type));
}
}
示例5: SerializeStreamHeader
private static void SerializeStreamHeader(ref int offsetFromStartOfMetadata, int alignedStreamSize, string streamName, BlobBuilder writer)
{
// 4 for the first uint (offset), 4 for the second uint (padded size), length of stream name + 1 for null terminator (then padded)
int sizeOfStreamHeader = MetadataSizes.GetMetadataStreamHeaderSize(streamName);
writer.WriteInt32(offsetFromStartOfMetadata);
writer.WriteInt32(alignedStreamSize);
foreach (char ch in streamName)
{
writer.WriteByte((byte)ch);
}
// After offset, size, and stream name, write 0-bytes until we reach our padded size.
for (uint i = 8 + (uint)streamName.Length; i < sizeOfStreamHeader; i++)
{
writer.WriteByte(0);
}
offsetFromStartOfMetadata += alignedStreamSize;
}
示例6: Serialize
internal protected override void Serialize(BlobBuilder builder, SectionLocation location)
{
builder.WriteInt32(0x12345678);
builder.WriteInt32(location.PointerToRawData);
builder.WriteInt32(location.RelativeVirtualAddress);
}
示例7: SerializeRowCounts
internal static void SerializeRowCounts(BlobBuilder writer, ImmutableArray<int> rowCounts)
{
for (int i = 0; i < rowCounts.Length; i++)
{
int rowCount = rowCounts[i];
if (rowCount > 0)
{
writer.WriteInt32(rowCount);
}
}
}