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


C# TypeDefinition.IsFlags方法代码示例

本文整理汇总了C#中Mono.Cecil.TypeDefinition.IsFlags方法的典型用法代码示例。如果您正苦于以下问题:C# TypeDefinition.IsFlags方法的具体用法?C# TypeDefinition.IsFlags怎么用?C# TypeDefinition.IsFlags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mono.Cecil.TypeDefinition的用法示例。


在下文中一共展示了TypeDefinition.IsFlags方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckType

        public RuleResult CheckType(TypeDefinition type)
        {
            // rule applies only to enums - but not enums marked with [Flags] attribute
            if (!type.IsEnum || type.IsFlags ())
                return RuleResult.DoesNotApply;

            // rule applies

            if (!IsPlural (type.Name))
                return RuleResult.Success;

            Runner.Report (type, Severity.Medium, Confidence.Normal);
            return RuleResult.Failure;
        }
开发者ID:FreeBSD-DotNet,项目名称:mono-tools,代码行数:14,代码来源:UseSingularNameInEnumsUnlessAreFlagsRule.cs

示例2: CheckType

        public RuleResult CheckType(TypeDefinition type)
        {
            // rule applies only to enums with [Flags] attribute
            if (!type.IsFlags ())
                return RuleResult.DoesNotApply;

            // rule applies

            if (IsPlural (type.Name))
                return RuleResult.Success;

            // Confidence == Normal because valid names may end with 's'
            Runner.Report (type, Severity.Low, Confidence.Normal);
            return RuleResult.Failure;
        }
开发者ID:alfredodev,项目名称:mono-tools,代码行数:15,代码来源:UsePluralNameInEnumFlagsRule.cs

示例3: CheckType

		public RuleResult CheckType (TypeDefinition type)
		{
			// rule apply only on [Flags] (this takes care of checking for enums)
			if (!type.IsFlags ())
				return RuleResult.DoesNotApply;

			// rule applies!

			FieldDefinition field = GetZeroValueField (type);
			if (field == null)
				return RuleResult.Success;

			// it's less likely an error if the field is named "None"
			Severity s = field.Name == "None" ? Severity.Medium : Severity.High;
			Runner.Report (field, s, Confidence.Total);
			return RuleResult.Failure;
		}
开发者ID:FreeBSD-DotNet,项目名称:mono-tools,代码行数:17,代码来源:FlagsShouldNotDefineAZeroValueRule.cs

示例4: CheckType

		public RuleResult CheckType (TypeDefinition type)
		{
			// rule apply only on enums
			if (!type.IsEnum)
				return RuleResult.DoesNotApply;

			// rule doesn't apply on [Flags]
			if (type.IsFlags ())
				return RuleResult.DoesNotApply;

			// rule applies!

			FieldDefinition field = GetZeroValueField (type);
			if (field != null)
				return RuleResult.Success;

			Runner.Report (type, Severity.Low, Confidence.Total);
			return RuleResult.Failure;
		}
开发者ID:FreeBSD-DotNet,项目名称:mono-tools,代码行数:19,代码来源:EnumsShouldDefineAZeroValueRule.cs

示例5: CheckType

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

			if (type.IsFlags ())
				return RuleResult.DoesNotApply;

			GetValues (type);
			if (values.Count < 3)
				return RuleResult.Success;

#if DEBUG
			Log.WriteLine (this);
			Log.WriteLine (this, "------------------------------------");
			Log.WriteLine (this, type.FullName);
			Log.WriteLine (this, "values: {0}", string.Join (" ", (from x in values select x.ToString ("X4")).ToArray ()));
#endif

			int numFlags = 0;
			int numMasks = 0;
			foreach (ulong value in values) {
				if (IsPowerOfTwo (value))
					++numFlags;
				else if (IsBitmask (value))
					++numMasks;
			}
			
			Log.WriteLine (this, "numFlags: {0}", numFlags);
			Log.WriteLine (this, "numMasks: {0}", numMasks);

			// The enum is bad if all of the values are powers of two or composed 
			// of defined powers of two,
			if (numFlags + numMasks == values.Count) {
				values.Sort ();		// sometimes enums are all sequential but not in order
				
				int numSequential = CountSequential ();				
				Log.WriteLine (this, "numSequential: {0}", numSequential);

				// and there are not too many sequential values (so we don't
				// complain about stuff like 1, 2, 3, 4, 5, 6).
				if (numSequential < 3) {
					Confidence confidence = values.Count >= 4 && numMasks == 0 ? Confidence.High : Confidence.Normal;
					Runner.Report (type, Severity.Medium, confidence);
				}
			}

			return Runner.CurrentRuleResult;
		}
开发者ID:nolanlum,项目名称:mono-tools,代码行数:49,代码来源:UseFlagsAttributeRule.cs


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