本文整理汇总了C#中IMetaDataImport.GetCustomAttributeByName方法的典型用法代码示例。如果您正苦于以下问题:C# IMetaDataImport.GetCustomAttributeByName方法的具体用法?C# IMetaDataImport.GetCustomAttributeByName怎么用?C# IMetaDataImport.GetCustomAttributeByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMetaDataImport
的用法示例。
在下文中一共展示了IMetaDataImport.GetCustomAttributeByName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HasAttribute
public static bool HasAttribute(IMetaDataImport mdi, uint token, string attributeName) {
if (mdi == null)
return false;
return mdi.GetCustomAttributeByName(token, attributeName, IntPtr.Zero, IntPtr.Zero) == 0;
}
示例2: HasAttribute
public static bool HasAttribute(IMetaDataImport mdi, uint token, string attributeName) {
if (mdi == null)
return false;
IntPtr addr;
uint size;
return mdi.GetCustomAttributeByName(token, attributeName, out addr, out size) == 0;
}
示例3: GetCustomAttributeByName
public unsafe static byte[] GetCustomAttributeByName(IMetaDataImport mdi, uint token, string name) {
if (mdi == null)
return null;
IntPtr addr;
uint size;
int hr = mdi.GetCustomAttributeByName(token, name, new IntPtr(&addr), new IntPtr(&size));
if (hr < 0 || addr == IntPtr.Zero)
return null;
var data = new byte[size];
Marshal.Copy(addr, data, 0, data.Length);
return data;
}
示例4: GetDebuggerBrowsableState
static DebuggerBrowsableState? GetDebuggerBrowsableState(IMetaDataImport mdi, uint token) {
Debug.Assert(new MDToken(token).Table == Table.Field || new MDToken(token).Table == Table.Property);
if (mdi == null)
return null;
IntPtr addr;
uint size;
int hr = mdi.GetCustomAttributeByName(token, "System.Diagnostics.DebuggerBrowsableAttribute", out addr, out size);
const int expectedLength = 8;
if (hr < 0 || addr == IntPtr.Zero || size != expectedLength)
return null;
var data = new byte[expectedLength];
Marshal.Copy(addr, data, 0, data.Length);
if (BitConverter.ToUInt16(data, 0) != 1)
return null;
var state = (DebuggerBrowsableState)BitConverter.ToInt32(data, 2);
if (BitConverter.ToUInt16(data, 6) != 0)
return null;
return state;
}