本文整理汇总了C#中MetadataReader.GetEventDefinition方法的典型用法代码示例。如果您正苦于以下问题:C# MetadataReader.GetEventDefinition方法的具体用法?C# MetadataReader.GetEventDefinition怎么用?C# MetadataReader.GetEventDefinition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MetadataReader
的用法示例。
在下文中一共展示了MetadataReader.GetEventDefinition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ValidateEvent
/// <summary>
/// EventMap Table Columns:
/// Parent (RID to TypeDef)
/// EventList (RID to EventTable)
/// ===========================================
/// Event Table Columns:
/// Name (offset to #String)
/// Flags (2 byte unsigned)
/// EventType (token to TypeDefOrRef)
/// </summary>
private void ValidateEvent(MetadataReader reader, uint rowId, uint startIdx, uint count, bool isVBMod = false)
{
if (0 == count)
{
return;
}
var expNames = new string[] { "E01", "E01", "CS1IGoo<System.Linq.Expressions.Expression,System.Object>.E01" };
// ModuleVB01
// Map: 0:TypeDef[2000003], 1:Event[14000001]
// Event: 0:0000, 1:string#1c6, 2:TypeDefOrRef[02000006]
var modNames = new string[] { "AnEvent" };
var modTokens = new uint[] { 0x02000006 };
uint zeroBased = startIdx - 1;
uint delta = count;
// Last one
if (0xF0000000 == count)
{
delta = (uint)reader.EventTable.NumberOfRows - zeroBased;
if (0 == delta)
{
return;
}
}
// Validity Rules
Assert.InRange((uint)reader.EventTable.NumberOfRows, zeroBased + count, uint.MaxValue);
for (uint i = zeroBased; i < zeroBased + count; i++)
{
var handle = EventDefinitionHandle.FromRowId((int)i + 1);
var evnt = reader.GetEventDefinition(handle);
// Name
if (isVBMod)
{
Assert.Equal(modNames[i], reader.GetString(evnt.Name));
}
else
{
Assert.Equal(expNames[i], reader.GetString(evnt.Name));
}
Assert.Equal(0, (ushort)evnt.Attributes);
if (isVBMod)
{
Assert.Equal(modTokens[i], (uint)evnt.Type.Token);
}
else
{
Assert.Equal((int)rowId, evnt.Type.RowId); // could be TypeSpec Id if it's in generic
}
}
}