本文整理汇总了C#中MetadataReader.GetFieldDefinition方法的典型用法代码示例。如果您正苦于以下问题:C# MetadataReader.GetFieldDefinition方法的具体用法?C# MetadataReader.GetFieldDefinition怎么用?C# MetadataReader.GetFieldDefinition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MetadataReader
的用法示例。
在下文中一共展示了MetadataReader.GetFieldDefinition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ValidateFieldDef
/// <summary>
/// Field Table Columns:
/// Name (offset to #String)
/// Flags (2 byte unsigned)
/// Signature (offset to #blob)
/// </summary>
private void ValidateFieldDef(MetadataReader reader, uint startIndex, uint count, bool isMod = false)
{
if (count == 0)
{
return;
}
// APPCS
var expNames = new string[] { "AppField01", "AppField02" };
var expFlags = new FieldAttributes[]
{
/*0x11*/
FieldAttributes.Private | FieldAttributes.Static,
/*0x01*/ FieldAttributes.Private,
};
var expSigs = new byte[][] { new byte[] { 0x06, 0x12, 0x11 }, new byte[] { 0x06, 0x12, 0x25 }, };
// =====================================================================================================
// VB Module - 8
var modNames = new string[] { "ConstString", "ArrayField", "AnEventEvent", "value__", "None", "Red", "Yellow", "Blue", };
var modFlags = new FieldAttributes[]
{
/* 0x8053 */
FieldAttributes.HasDefault | FieldAttributes.Literal | FieldAttributes.Static | FieldAttributes.FamANDAssem | FieldAttributes.Private,
/* 0x0016 */ FieldAttributes.Static | FieldAttributes.Family | FieldAttributes.FamANDAssem,
/* 0x0001 */ FieldAttributes.Private,
/* 0x0606 */ FieldAttributes.RTSpecialName | FieldAttributes.SpecialName | FieldAttributes.Family | FieldAttributes.FamANDAssem,
/* 0x8056 */ FieldAttributes.HasDefault | FieldAttributes.Literal | FieldAttributes.Static | FieldAttributes.Family | FieldAttributes.FamANDAssem,
/* 0x8056 */ FieldAttributes.HasDefault | FieldAttributes.Literal | FieldAttributes.Static | FieldAttributes.Family | FieldAttributes.FamANDAssem,
/* 0x8056 */ FieldAttributes.HasDefault | FieldAttributes.Literal | FieldAttributes.Static | FieldAttributes.Family | FieldAttributes.FamANDAssem,
/* 0x8056 */ FieldAttributes.HasDefault | FieldAttributes.Literal | FieldAttributes.Static | FieldAttributes.Family | FieldAttributes.FamANDAssem,
};
var modSigs = new byte[][]
{
new byte[] { 0x06, 0x0e }, new byte[] { 0x06, 0x14, 0x11, 0x14, 02, 00, 02, 00, 00 },
new byte[] { 0x06, 0x12, 0x18 }, new byte[] { 0x06, 0x08 },
new byte[] { 0x06, 0x11, 0x10 }, new byte[] { 0x06, 0x11, 0x10 },
new byte[] { 0x06, 0x11, 0x10 }, new byte[] { 0x06, 0x11, 0x10 },
};
if (startIndex > reader.FieldTable.NumberOfRows)
{
return;
}
uint zeroBased = startIndex - 1;
uint delta = count;
// Last one
if (0xF0000000 == count)
{
delta = (uint)reader.FieldTable.NumberOfRows - zeroBased;
if (0 == delta)
{
return;
}
}
Assert.InRange((uint)reader.FieldTable.NumberOfRows, zeroBased + delta, uint.MaxValue); // 1 based
for (uint i = zeroBased; i < zeroBased + delta; i++)
{
var handle = FieldDefinitionHandle.FromRowId((int)(i + 1));
var row = reader.GetFieldDefinition(handle);
if (isMod)
{
Assert.Equal(modNames[i], reader.GetString(row.Name));
Assert.Equal(modFlags[i], row.Attributes);
}
else
{
Assert.Equal(expNames[i], reader.GetString(row.Name));
Assert.Equal(expFlags[i], row.Attributes);
}
var sig = reader.GetBlobBytes(row.Signature);
// calling convention, always 6 for field
Assert.Equal(sig[0], 6);
int len = 0;
if (isMod)
{
len = modSigs[i].Length;
}
else
{
len = expSigs[i].Length;
}
for (int j = 1; j < len; j++)
{
if (isMod)
{
Assert.Equal(modSigs[i][j], sig[j]);
//.........这里部分代码省略.........
示例2: GetFieldInformation
private static string GetFieldInformation(MetadataReader metadataReader, int intOperand, CilTypeProvider provider)
{
if(IsMemberReference(intOperand))
{
return GetMemberRef(metadataReader, intOperand, provider);
}
var handle = MetadataTokens.FieldDefinitionHandle(intOperand);
var definition = metadataReader.GetFieldDefinition(handle);
var typeHandle = definition.GetDeclaringType();
var typeSignature = SignatureDecoder.DecodeType(typeHandle, provider, null);
var signature = SignatureDecoder.DecodeFieldSignature(definition.Signature, provider);
return String.Format("{0} {1}::{2}", signature.ToString(), typeSignature.ToString(false), GetString(metadataReader, definition.Name));
}