当前位置: 首页>>代码示例>>C#>>正文


C# ICustomAttributeProvider.HasAttribute方法代码示例

本文整理汇总了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;
 }
开发者ID:Filiecs,项目名称:U-EAT,代码行数:31,代码来源:Boolean3.cs

示例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);
		}
开发者ID:HaKDMoDz,项目名称:InVision,代码行数:46,代码来源:ConfigOptions.cs

示例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);
		}
开发者ID:col42dev,项目名称:mono-tools,代码行数:15,代码来源:CentralizePInvokesIntoNativeMethodsTypeRule.cs

示例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;
 }
开发者ID:Filiecs,项目名称:U-EAT,代码行数:30,代码来源:Integer2.cs


注:本文中的ICustomAttributeProvider.HasAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。