本文整理汇总了C#中IMetaDataImport.EnumParams方法的典型用法代码示例。如果您正苦于以下问题:C# IMetaDataImport.EnumParams方法的具体用法?C# IMetaDataImport.EnumParams怎么用?C# IMetaDataImport.EnumParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMetaDataImport
的用法示例。
在下文中一共展示了IMetaDataImport.EnumParams方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetParamTokens
public unsafe static uint[] GetParamTokens(IMetaDataImport mdi, uint token) {
if (mdi == null)
return new uint[0];
IntPtr iter = IntPtr.Zero;
try {
uint cTokens;
int hr = mdi.EnumParams(ref iter, token, 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.EnumParams(ref iter, token, 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: _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);
}
}
//.........这里部分代码省略.........