本文整理汇总了C#中IMetaDataImport.CountEnum方法的典型用法代码示例。如果您正苦于以下问题:C# IMetaDataImport.CountEnum方法的具体用法?C# IMetaDataImport.CountEnum怎么用?C# IMetaDataImport.CountEnum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMetaDataImport
的用法示例。
在下文中一共展示了IMetaDataImport.CountEnum方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetTypeDefTokens
public unsafe static uint[] GetTypeDefTokens(IMetaDataImport mdi) {
if (mdi == null)
return new uint[0];
IntPtr iter = IntPtr.Zero;
try {
uint count;
int hr = mdi.EnumTypeDefs(ref iter, IntPtr.Zero, 0, out count);
if (hr < 0)
return new uint[0];
uint ulCount = 0;
hr = mdi.CountEnum(iter, ref ulCount);
if (hr < 0)
return new uint[0];
hr = mdi.ResetEnum(iter, 0);
if (hr < 0)
return new uint[0];
// The global type isn't included
uint[] tokens = new uint[ulCount + 1];
if (tokens.Length > 1) {
fixed (uint* p = &tokens[1])
hr = mdi.EnumTypeDefs(ref iter, new IntPtr(p), ulCount, out count);
}
if (hr < 0)
return new uint[0];
tokens[0] = 0x02000001;
return tokens;
}
finally {
if (iter != IntPtr.Zero)
mdi.CloseEnum(iter);
}
}
示例2: GetPermissionSetTokens
public unsafe static uint[] GetPermissionSetTokens(IMetaDataImport mdi, uint token) {
if (mdi == null)
return new uint[0];
IntPtr iter = IntPtr.Zero;
try {
uint cTokens;
int hr = mdi.EnumPermissionSets(ref iter, token, 0, IntPtr.Zero, 0, out cTokens);
if (hr < 0)
return new uint[0];
uint ulCount = 0;
hr = mdi.CountEnum(iter, ref ulCount);
if (hr < 0 || ulCount == 0)
return new uint[0];
hr = mdi.ResetEnum(iter, 0);
if (hr < 0)
return new uint[0];
uint[] tokens = new uint[ulCount];
fixed (uint* p = &tokens[0])
hr = mdi.EnumPermissionSets(ref iter, token, 0, new IntPtr(p), (uint)tokens.Length, out cTokens);
if (hr < 0)
return new uint[0];
return tokens;
}
finally {
if (iter != IntPtr.Zero)
mdi.CloseEnum(iter);
}
}
示例3: GetMethodOverrides
public unsafe static MethodOverrideInfo[] GetMethodOverrides(IMetaDataImport mdi, uint token) {
if (mdi == null)
return new MethodOverrideInfo[0];
IntPtr iter = IntPtr.Zero;
try {
uint cTokens;
int hr = mdi.EnumMethodImpls(ref iter, token, IntPtr.Zero, IntPtr.Zero, 0, out cTokens);
if (hr < 0)
return new MethodOverrideInfo[0];
uint ulCount = 0;
hr = mdi.CountEnum(iter, ref ulCount);
if (hr < 0 || ulCount == 0)
return new MethodOverrideInfo[0];
hr = mdi.ResetEnum(iter, 0);
if (hr < 0)
return new MethodOverrideInfo[0];
uint[] bodyTokens = new uint[ulCount];
uint[] declTokens = new uint[ulCount];
fixed (uint* b = &bodyTokens[0]) {
fixed (uint* d = &declTokens[0])
hr = mdi.EnumMethodImpls(ref iter, token, new IntPtr(b), new IntPtr(d), (uint)bodyTokens.Length, out cTokens);
}
if (hr < 0)
return new MethodOverrideInfo[0];
var infos = new MethodOverrideInfo[ulCount];
for (int i = 0; i < infos.Length; i++)
infos[i] = new MethodOverrideInfo(bodyTokens[i], declTokens[i]);
return infos;
}
finally {
if (iter != IntPtr.Zero)
mdi.CloseEnum(iter);
}
}