本文整理汇总了C#中IMetaDataImport.CloseEnum方法的典型用法代码示例。如果您正苦于以下问题:C# IMetaDataImport.CloseEnum方法的具体用法?C# IMetaDataImport.CloseEnum怎么用?C# IMetaDataImport.CloseEnum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMetaDataImport
的用法示例。
在下文中一共展示了IMetaDataImport.CloseEnum方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
}
示例2: 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);
}
}
示例3: _GetFieldTokens
internal uint[] _GetFieldTokens(IMetaDataImport importer, ICorDebugClass iclass)
{
uint ctoken;
iclass.GetToken(out ctoken);
uint henum = 0;
List<uint> fieldtoks = new List<uint>();
try
{
uint[] aonefieldtok = new uint[1];
for (; ; )
{
uint count;
importer.EnumFields(ref henum, ctoken, aonefieldtok, 1, out count);
if (1 != count)
{
break;
}
fieldtoks.Add(aonefieldtok[0]);
}
}
finally
{
importer.CloseEnum(henum);
}
return fieldtoks.ToArray();
}
示例4: 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);
}
}
示例5: _PrintArgs
static void _PrintArgs(ICorDebugILFrame ilframe, IMetaDataImport importer, System.IO.TextWriter writer)
{
uint argcount;
{
ICorDebugValueEnum ven;
ilframe.EnumerateArguments(out ven);
ven.GetCount(out argcount);
}
if (argcount < 1)
{
return;
}
uint ftoken;
ilframe.GetFunctionToken(out ftoken);
System.Reflection.MethodAttributes fattribs;
{
uint chMethod;
uint dwAttr;
IntPtr pvSigBlob;
uint cbSigBlob;
uint ulCodeRVA;
uint dwImplFlags;
uint ftypedeftoken;
int hrmethodprops = (int)importer.GetMethodProps(ftoken, out ftypedeftoken,
null, 0, out chMethod,
out dwAttr,
out pvSigBlob, out cbSigBlob,
out ulCodeRVA, out dwImplFlags);
Marshal.ThrowExceptionForHR(hrmethodprops);
char[] methodnamechars = new char[chMethod];
hrmethodprops = (int)importer.GetMethodProps(ftoken, out ftypedeftoken,
methodnamechars, (uint)methodnamechars.Length, out chMethod,
out dwAttr,
out pvSigBlob, out cbSigBlob,
out ulCodeRVA, out dwImplFlags);
Marshal.ThrowExceptionForHR(hrmethodprops);
chMethod--; // Remove nul.
//MethodName = new string(methodnamechars, 0, (int)chMethod);
fattribs = (System.Reflection.MethodAttributes)dwAttr;
}
List<uint> paramtoks = new List<uint>();
{
uint henum = 0;
try
{
uint[] aoneparamtok = new uint[1];
for (; ; )
{
uint count;
importer.EnumParams(ref henum, ftoken, aoneparamtok, 1, out count);
if (1 != count)
{
break;
}
paramtoks.Add(aoneparamtok[0]);
}
}
finally
{
importer.CloseEnum(henum);
}
}
uint ia = 0;
int ip = 0; //paramtoks.Count - (int)argcount;
for (; ia < argcount; ia++)
{
string argname;
if (0 == ia
&& System.Reflection.MethodAttributes.Static != (fattribs & System.Reflection.MethodAttributes.Static))
{
argname = "this";
}
else
{
if (ip >= paramtoks.Count)
{
argname = "unnamed_param_" + (1 + ia).ToString();
}
else
{
{
uint ptok = paramtoks[ip++];
uint parenttok;
uint pulSequence;
uint argnamelen = 0;
uint dwAttr, dwCPlusTypeFlag, cchValue;
IntPtr pValue;
importer.GetParamProps(ptok, out parenttok, out pulSequence, null, argnamelen, out argnamelen,
out dwAttr, out dwCPlusTypeFlag, out pValue, out cchValue);
char[] argnamebuf = new char[argnamelen];
importer.GetParamProps(ptok, out parenttok, out pulSequence, argnamebuf, argnamelen, out argnamelen,
out dwAttr, out dwCPlusTypeFlag, out pValue, out cchValue);
argnamelen--; // Remove nul.
argname = new string(argnamebuf, 0, (int)argnamelen);
}
}
//.........这里部分代码省略.........