當前位置: 首頁>>代碼示例>>C#>>正文


C# TypeDefinition.HasAttribute方法代碼示例

本文整理匯總了C#中Mono.Cecil.TypeDefinition.HasAttribute方法的典型用法代碼示例。如果您正苦於以下問題:C# TypeDefinition.HasAttribute方法的具體用法?C# TypeDefinition.HasAttribute怎麽用?C# TypeDefinition.HasAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Mono.Cecil.TypeDefinition的用法示例。


在下文中一共展示了TypeDefinition.HasAttribute方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CheckType

		// The [SuppressUnmanagedCodeSecurity] attribute applies to
		// Classes, Interfaces, Delegates (ITypeRule) and Methods (IMethodRule)

		public RuleResult CheckType (TypeDefinition type)
		{
			if (type.IsEnum)
				return RuleResult.DoesNotApply;

			if (!type.HasAttribute (SUCS))
				return RuleResult.Success;

			Runner.Report (type, Severity.Audit, Confidence.Total);
			return RuleResult.Failure;
		}
開發者ID:boothead,項目名稱:mono-tools,代碼行數:14,代碼來源:ReviewSuppressUnmanagedCodeSecurityUsageRule.cs

示例2: CheckType

		// The [SuppressUnmanagedCodeSecurity] attribute applies to
		// Classes, Interfaces, Delegates (ITypeRule) and Methods (IMethodRule)

		public RuleResult CheckType (TypeDefinition type)
		{
			if (type.IsEnum)
				return RuleResult.DoesNotApply;

			if (!type.HasAttribute ("System.Security", "SuppressUnmanagedCodeSecurityAttribute"))
				return RuleResult.Success;

			Runner.Report (type, Severity.Audit, Confidence.Total);
			return RuleResult.Failure;
		}
開發者ID:FreeBSD-DotNet,項目名稱:mono-tools,代碼行數:14,代碼來源:ReviewSuppressUnmanagedCodeSecurityUsageRule.cs

示例3: CheckType

		public RuleResult CheckType (TypeDefinition type)
		{
			// rule applies only to attributes
			if (!type.IsAttribute ())
				return RuleResult.DoesNotApply;

			if (type.HasAttribute ("System", "AttributeUsageAttribute")) // it's ok
				return RuleResult.Success;

			Runner.Report (type, Severity.High, Confidence.Total);
			return RuleResult.Failure;
		}
開發者ID:FreeBSD-DotNet,項目名稱:mono-tools,代碼行數:12,代碼來源:MissingAttributeUsageOnCustomAttributeRule.cs

示例4: CreateTypeToRewrite

 private TypeToRewrite CreateTypeToRewrite(TypeDefinition type)
 {
     var markedWithTrackChanges = type.HasAttribute<TrackChangesAttribute>();
     var parent = type.BaseType.Name == "Object" || markedWithTrackChanges || parameters.IsForeign(type.BaseType)
                      ? null
                      : GetTypeToRewrite(type.BaseType.Resolve());
     return new TypeToRewrite
         {
             hierarchyMarkedWithTrackChangesAttribute = markedWithTrackChanges ||
                                                        parent != null && parent.hierarchyMarkedWithTrackChangesAttribute,
             parent = parent,
             type = type
         };
 }
開發者ID:gusev-p,項目名稱:Aop,代碼行數:14,代碼來源:ChangeTrackingRewriter.cs

示例5: NeedTrackType

 public bool NeedTrackType(TypeDefinition typeDefinition)
 {
     if (typeDefinition.Name == "<Module>")
         return false;
     if (typeDefinition.IsValueType)
         return false;
     if (typeDefinition.IsNested && !parameters.ProcessNestedTypes)
         return false;
     if (typeDefinition.IsInterface)
         return false;
     if (typeDefinition.HasAttribute<CompilerGeneratedAttribute>())
         return false;
     return true;
 }
開發者ID:gusev-p,項目名稱:Aop,代碼行數:14,代碼來源:ChangeTrackingScheme.cs

示例6: CheckType

        // Type			Visible		Non-Visible
        // ------------------------------------------------
        // BaseType*		High		Medium
        // Interfaces*		Medium		Low
        // Fields		Medium		Low
        // Properties		High		Medium
        // Events		High		Medium
        // * type visibility
        public RuleResult CheckType(TypeDefinition type)
        {
            // we're not interested in the details of [Obsolete] types
            if (type.HasAttribute ("System", "ObsoleteAttribute"))
                return RuleResult.DoesNotApply;

            // check if we inherit from an [Obsolete] class / struct / enum
            CheckBaseType (type);

            // check if we implement an [Obsolete] interface
            if (type.HasInterfaces)
                CheckInterfaces (type);

            // check fields types
            if (type.HasFields)
                CheckFields (type);

            // check properties (not the getter / setter)
            if (type.HasProperties)
                CheckProperties (type);

            // check events (not add / remove / invoke)
            if (type.HasEvents)
                CheckEvents (type);

            return Runner.CurrentRuleResult;
        }
開發者ID:alfredodev,項目名稱:mono-tools,代碼行數:35,代碼來源:RemoveDependenceOnObsoleteCodeRule.cs

示例7: UsedForComInterop

		private static bool UsedForComInterop (TypeDefinition type)
		{
			return (type.IsInterface && type.HasAttribute (GuidAttribute) &&
				type.HasAttribute (InterfaceTypeAttribute));
		}
開發者ID:nolanlum,項目名稱:mono-tools,代碼行數:5,代碼來源:DetectNonAlphaNumericsInTypeNamesRule.cs

示例8: UsedForComInterop

		private static bool UsedForComInterop (TypeDefinition type)
		{
			return (type.IsInterface && type.HasAttribute ("System.Runtime.InteropServices", "GuidAttribute") &&
				type.HasAttribute ("System.Runtime.InteropServices", "InterfaceTypeAttribute"));
		}
開發者ID:col42dev,項目名稱:mono-tools,代碼行數:5,代碼來源:DetectNonAlphaNumericsInTypeNamesRule.cs


注:本文中的Mono.Cecil.TypeDefinition.HasAttribute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。