本文整理汇总了C#中ICustomAttributeProvider.HasAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# ICustomAttributeProvider.HasAttribute方法的具体用法?C# ICustomAttributeProvider.HasAttribute怎么用?C# ICustomAttributeProvider.HasAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICustomAttributeProvider
的用法示例。
在下文中一共展示了ICustomAttributeProvider.HasAttribute方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw3
public static ReferenceType<Boolean3> Draw3(Rect position, object eventsObj, GUIContent content, ICustomAttributeProvider info = null)
{
Boolean3 boolPair = (Boolean3)eventsObj;
var boolArray = new bool[] { boolPair.x, boolPair.y, boolPair.z };
Builder = new StringBuilder();
char flags = (char)EditorNameFlags.Default;
if (info != null && info.HasAttribute(typeof(CustomNamesAttribute)))
{
CustomNamesAttribute attribute = info.GetCustomAttributes<CustomNamesAttribute>()[0];
flags = (char)attribute.CustomFlags;
Builder.Append(flags);
if (attribute.UseVariableNameAsTitle)
{
Builder.Append(Seperator);
Builder.Append(content.text);
}
Builder.Append(attribute.CombinedName);
}
else
{
Builder.Append(flags);
Builder.Append(Seperator);
Builder.Append(content.text);
}
content.text = Builder.ToString();
DrawMultiBoolean(ref boolArray, position, content);
boolPair.x = boolArray[0];
boolPair.y = boolArray[1];
boolPair.z = boolArray[2];
return boolPair;
}
示例2: ToCppTypename
/// <summary>
/// Translates the type.
/// </summary>
/// <param name="fieldInfo">The field info.</param>
/// <param name="fieldType">Type of the field.</param>
/// <returns></returns>
public static string ToCppTypename(ICustomAttributeProvider fieldInfo, Type fieldType)
{
string translatedType;
if (fieldType == typeof(string)) {
return fieldInfo.HasAttribute<MarshalAsAttribute>() &&
fieldInfo.GetAttribute<MarshalAsAttribute>(false).Value == UnmanagedType.LPStr
? "_string"
: "_wstring";
}
if (TranslatedTypes.TryGetValue(fieldType, out translatedType))
return translatedType;
if (fieldType.IsByRef) {
string pointedTypename = fieldType.FullName.Substring(0, fieldType.FullName.Length - 1);
Type pointedType = fieldType.Assembly.GetType(pointedTypename);
return ToCppTypename(fieldInfo, pointedType) + "*";
}
if (fieldType.IsArray) {
return ToCppTypename(fieldInfo, fieldType.GetElementType()) + "*";
}
if (fieldType.IsPointer) {
string pointedTypename = fieldType.FullName.Substring(0, fieldType.FullName.Length - 1);
Type pointedType = fieldType.Assembly.GetType(pointedTypename);
return ToCppTypename(fieldInfo, pointedType) + "*";
}
if (fieldType.IsEnum)
return GetCppEnumName(fieldType);
if (fieldType.HasICppInterface())
return ToCppTypename(fieldInfo, typeof(Handle));
return GetCppTypename(fieldType);
}
示例3: CheckSuppressUnmanagedCodeSecurity
private void CheckSuppressUnmanagedCodeSecurity (ICustomAttributeProvider type, bool required)
{
string msg = null;
if (type.HasAttribute ("System.Security", "SuppressUnmanagedCodeSecurityAttribute")) {
if (!required)
msg = "Remove [SuppressUnmanagedCodeSecurity] attribute on the type declaration.";
} else {
// no [SuppressUnmanagedCodeSecurity] attribute
if (required)
msg = "Add missing [SuppressUnmanagedCodeSecurity] attribute on the type declaration.";
}
if (msg != null)
Runner.Report (type, Severity.Critical, Confidence.Total, msg);
}
示例4: Draw2
public static ReferenceType<Integer2> Draw2(Rect position, object eventsObj, GUIContent content, ICustomAttributeProvider info = null)
{
Integer2 intPair = (Integer2)eventsObj;
var intArray = new int[2]{ intPair.x, intPair.y };
Builder = new StringBuilder();
char flags = (char)EditorNameFlags.Default;
if (info != null && info.HasAttribute(typeof(CustomNamesAttribute)))
{
CustomNamesAttribute attribute = info.GetCustomAttributes<CustomNamesAttribute>()[0];
flags = (char)attribute.CustomFlags;
Builder.Append(flags);
if(attribute.UseVariableNameAsTitle)
{
Builder.Append(Seperator);
Builder.Append(content.text);
}
Builder.Append(attribute.CombinedName);
}
else
{
Builder.Append(flags);
Builder.Append(Seperator);
Builder.Append(content.text);
}
content.text = Builder.ToString();
DrawMultiInteger(ref intArray, position, content);
intPair.x = intArray[0];
intPair.y = intArray[1];
return intPair;
}