本文整理汇总了C#中System.Compiler.Field.GetAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# Field.GetAttribute方法的具体用法?C# Field.GetAttribute怎么用?C# Field.GetAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Compiler.Field
的用法示例。
在下文中一共展示了Field.GetAttribute方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FieldIsElementsPeer
public static bool FieldIsElementsPeer(Field f)
{
if (f == null) return false;
return f.GetAttribute(SystemTypes.ElementsPeerAttribute) != null;
}
示例2: FieldIsAdditive
public static bool FieldIsAdditive(Field field) {
if (field == null) return false;
AttributeNode attr = field.GetAttribute(SystemTypes.AdditiveAttribute);
if (attr == null) return false;
ExpressionList exprs = attr.Expressions;
if (exprs == null || exprs.Count != 1) return true;
Literal lit = exprs[0] as Literal;
if (lit != null && (lit.Value is bool)) return (bool)lit.Value;
else return false;
}
示例3: VisitField
public override Field VisitField(Field field) {
Field retVal = base.VisitField(field);
AttributeNode attrNode = field.GetAttribute(SystemTypes.AdditiveAttribute);
bool isAdditive = IsAdditive(attrNode);
if (isAdditive && attrNode != null) {
if (field.IsPrivate) {
this.HandleError(attrNode, Error.AttributeNotAllowedOnPrivateMember, this.GetTypeName(attrNode.Type));
}
}
#region Can't have both [Rep] and [Additive] (or Rep's owned synonyms)
if (MemberIsRep(field) && isAdditive) {
this.HandleError(field, Error.ConflictingAttributes, this.GetTypeName(SystemTypes.RepAttribute),
this.GetTypeName(SystemTypes.AdditiveAttribute));
}
#endregion
return retVal;
}