本文整理匯總了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;
}