本文整理汇总了C#中IMetaDataImport.GetFieldProps方法的典型用法代码示例。如果您正苦于以下问题:C# IMetaDataImport.GetFieldProps方法的具体用法?C# IMetaDataImport.GetFieldProps怎么用?C# IMetaDataImport.GetFieldProps使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMetaDataImport
的用法示例。
在下文中一共展示了IMetaDataImport.GetFieldProps方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFieldAttributes
public unsafe static FieldAttributes GetFieldAttributes(IMetaDataImport mdi, uint token) {
uint dwAttr;
int hr = mdi.GetFieldProps(token, IntPtr.Zero, IntPtr.Zero, 0, IntPtr.Zero, new IntPtr(&dwAttr), IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
Debug.Assert(hr == 0);
return hr < 0 ? 0 : (FieldAttributes)dwAttr;
}
示例2: GetFieldConstant
public unsafe static object GetFieldConstant(IMetaDataImport mdi, uint token, out CorElementType constantType) {
constantType = CorElementType.End;
if (mdi == null)
return null;
uint cchValue;
IntPtr pValue;
CorElementType constantTypeTmp;
int hr = mdi.GetFieldProps(token, IntPtr.Zero, IntPtr.Zero, 0, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, new IntPtr(&constantTypeTmp), new IntPtr(&pValue), new IntPtr(&cchValue));
if (hr < 0 || pValue == IntPtr.Zero)
return null;
constantType = constantTypeTmp;
return ReadConstant(pValue, cchValue, constantType);
}
示例3: GetFieldName
public static unsafe string GetFieldName(IMetaDataImport mdi, uint token) {
if (mdi == null)
return null;
uint chField = 0, dwAttr = 0;
char[] nameBuf = null;
int hr = mdi.GetFieldProps(token, IntPtr.Zero, IntPtr.Zero, 0, new IntPtr(&chField), new IntPtr(&dwAttr), IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
if (hr >= 0 && chField != 0) {
nameBuf = new char[chField];
fixed (char* p = &nameBuf[0])
hr = mdi.GetFieldProps(token, IntPtr.Zero, new IntPtr(p), (uint)nameBuf.Length, new IntPtr(&chField), IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
}
if (hr < 0)
return null;
if (chField <= 1)
return string.Empty;
return new string(nameBuf, 0, (int)chField - 1);
}
示例4: GetFieldSignatureBlob
public static unsafe byte[] GetFieldSignatureBlob(IMetaDataImport mdi, uint token) {
if (mdi == null)
return null;
uint sigLen = 0;
IntPtr sigAddr;
int hr = mdi.GetFieldProps(token, IntPtr.Zero, IntPtr.Zero, 0, IntPtr.Zero, IntPtr.Zero, new IntPtr(&sigAddr), new IntPtr(&sigLen), IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
if (hr < 0 || sigAddr == IntPtr.Zero)
return null;
var buf = new byte[sigLen];
Marshal.Copy(sigAddr, buf, 0, buf.Length);
return buf;
}
示例5: GetFieldOwnerRid
public unsafe static uint GetFieldOwnerRid(IMetaDataImport mdi, uint token) {
if (mdi == null)
return 0;
if (IsGlobal(mdi, token))
return 1;
uint ownerToken;
int hr = mdi.GetFieldProps(token, new IntPtr(&ownerToken), IntPtr.Zero, 0, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
if (hr != 0)
return 0;
var ownerMdToken = new MDToken(ownerToken);
return ownerMdToken.Table == Table.TypeDef ? ownerMdToken.Rid : 0;
}
示例6: _FieldNameFromToken
internal string _FieldNameFromToken(IMetaDataImport importer, uint fieldtok)
{
uint fieldnamelen = 0;
uint dwAttr;
IntPtr pvSigBlob;
uint cbSigBlob, dwCPlusTypeFlag;
IntPtr pValue;
uint cchValue;
uint classtypetok;
// 33554432/0x02000000 class type refers to the base type.
importer.GetFieldProps(fieldtok, out classtypetok, null, fieldnamelen, out fieldnamelen,
out dwAttr, out pvSigBlob, out cbSigBlob, out dwCPlusTypeFlag, out pValue, out cchValue);
char[] fieldnamebuf = new char[fieldnamelen];
importer.GetFieldProps(fieldtok, out classtypetok, fieldnamebuf, fieldnamelen, out fieldnamelen,
out dwAttr, out pvSigBlob, out cbSigBlob, out dwCPlusTypeFlag, out pValue, out cchValue);
if (0 == fieldnamelen)
{
return null;
}
fieldnamelen--; // Remove nul.
string fieldname = new string(fieldnamebuf, 0, (int)fieldnamelen);
return fieldname;
}
示例7: GetFieldAttributes
static FieldAttributes GetFieldAttributes(IMetaDataImport mdi, uint token) {
uint chField, dwAttr;
int hr = mdi.GetFieldProps(token, IntPtr.Zero, IntPtr.Zero, 0, out chField, out dwAttr, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
return hr < 0 ? 0 : (FieldAttributes)dwAttr;
}
示例8: FieldIsStatic
public static bool FieldIsStatic(IMetaDataImport mdi, uint tk)
{
int dwAttr;
mdi.GetFieldProps(tk, IntPtr.Zero, IntPtr.Zero, 0, IntPtr.Zero, (IntPtr)(&dwAttr), IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
return (dwAttr & (int)CorFieldAttr.fdStatic) != 0;
}
示例9: FieldGetName
public static string FieldGetName(IMetaDataImport mdi, uint tk)
{
uint chName;
mdi.GetFieldProps(tk, IntPtr.Zero, IntPtr.Zero, 0, (IntPtr)(&chName), IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
char* szName = stackalloc char[(int)chName];
mdi.GetFieldProps(tk, IntPtr.Zero, (IntPtr)szName, chName, (IntPtr)(&chName), IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
return new string(szName);
}