本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}