本文整理汇总了C#中Method.GetAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# Method.GetAttribute方法的具体用法?C# Method.GetAttribute怎么用?C# Method.GetAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Method
的用法示例。
在下文中一共展示了Method.GetAttribute方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsAnnotated
public static bool IsAnnotated(Method m) {
bool res = m.GetAttribute(SystemTypes.WriteAttribute) != null;
res = res || m.GetAttribute(SystemTypes.WriteConfinedAttribute) != null;
res = res || m.GetAttribute(SystemTypes.GlobalWriteAttribute) != null;
res = res || m.GetAttribute(SystemTypes.GlobalReadAttribute) != null;
res = res || m.GetAttribute(SystemTypes.PureAttribute) != null;
if (m.Parameters != null) {
foreach (Parameter p in m.Parameters) {
res = res || p.GetAttribute(SystemTypes.ReadAttribute) != null;
res = res || p.GetAttribute(SystemTypes.PureAttribute) != null;
res = res || p.GetAttribute(SystemTypes.WriteAttribute) != null;
res = res || p.GetAttribute(SystemTypes.WriteConfinedAttribute) != null;
res = res || p.GetAttribute(SystemTypes.EscapesAttribute) != null;
}
}
return res;
}
示例2: IsDeclaredWrite
public static bool IsDeclaredWrite(Method m) {
if (WorstCase)
return true;
bool res = true;
AttributeNode attr = m.GetAttribute(SystemTypes.WriteAttribute);
if (attr != null) {
WriteAttribute wAttr = (WriteAttribute)attr.GetRuntimeAttribute();
res = wAttr.Value;
}
else
res = true;
return res;
}
示例3: IsEscaping
public static bool IsEscaping(Method m, out bool owned) {
if (WorstCase) {
owned = true;
return true;
}
bool res = false;
owned = false;
if (!m.IsStatic) {
if (m.GetAttribute(SystemTypes.CapturedAttribute) != null) {
owned = true;
return true;
}
}
AttributeNode attr = m.GetAttribute(SystemTypes.EscapesAttribute);
if (attr != null) {
EscapesAttribute escAttr = (EscapesAttribute)attr.GetRuntimeAttribute();
if (escAttr != null) {
res = escAttr.Value;
owned = escAttr.Owned;
}
}
return res && !IsConstructor(m);
}
示例4: IsDeclaredFresh
public static bool IsDeclaredFresh(Method m) {
if (WorstCase)
return false;
bool res = false;
res = m.GetAttribute(SystemTypes.FreshAttribute) != null;
if (m.ReturnAttributes != null && m.ReturnAttributes.Count != 0) {
foreach (AttributeNode attr in m.ReturnAttributes) {
res = res || attr.Type.Equals(SystemTypes.FreshAttribute);
}
}
return res;
}
示例5: IsDeclaredAccessingGlobals
public static bool IsDeclaredAccessingGlobals(Method m) {
if (WorstCase)
return true;
bool res = true;
AttributeNode attr = m.GetAttribute(SystemTypes.GlobalAccessAttribute);
if (attr != null) {
GlobalAccessAttribute readAttr = (GlobalAccessAttribute)attr.GetRuntimeAttribute();
if (readAttr != null)
res = readAttr.Value;
}
else {
if (IsAssumedConfinedMethod(m))
return false;
// We assume thet constructor are not writing globals
if (CciHelper.IsConstructor(m))
res = false;
//if (m.DeclaringType != null && CciHelper.IsInterface(m.DeclaringType)
// && m.DeclaringType.FullName.StartsWith("System.Collections"))
// return false;
}
return res;
}
示例6: IsDeclaredWritingGlobals
public static bool IsDeclaredWritingGlobals(Method m) {
if (WorstCase)
return true;
bool res = false;
AttributeNode attr = m.GetAttribute(SystemTypes.GlobalWriteAttribute);
if (attr != null) {
GlobalWriteAttribute writeAttr = (GlobalWriteAttribute)attr.GetRuntimeAttribute();
if (writeAttr != null)
res = writeAttr.Value;
}
else {
if (!IsDeclaredAccessingGlobals(m))
return false;
if (IsAssumedPureMethod(m)
|| IsDeclaredWriteConfined(m))
return false;
}
return res;
}
示例7: IsPurityForcedByUser
public static bool IsPurityForcedByUser(Method method) {
if (WorstCase)
return false;
bool res = false;
AttributeNode attr = method.GetAttribute(SystemTypes.PureAttribute);
if (attr != null) {
PureAttribute purity = (PureAttribute)attr.GetRuntimeAttribute();
if (purity != null)
return purity.IsAssumedPure;
}
return res;
}
示例8: IsModelUseOk
//invariants can only use confined and state independent functions
public virtual bool IsModelUseOk(Member member, Method method) {
if (member == null || method == null) return true;
if (member is ParameterField) return true;
if (member is Field) return true;
return (member.GetAttribute(SystemTypes.ModelAttribute)!= null) ? method.GetAttribute(SystemTypes.ModelAttribute)!= null: true;
}