本文整理汇总了C#中Member.GetAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# Member.GetAttribute方法的具体用法?C# Member.GetAttribute怎么用?C# Member.GetAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Member
的用法示例。
在下文中一共展示了Member.GetAttribute方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsSpecProtected
private bool IsSpecProtected(Member member) {
return member.GetAttribute(SystemTypes.SpecProtectedAttribute)!= null &&
this.GetTypeView(this.currentType).IsAssignableTo(member.DeclaringType) &&
this.currentType.NodeType==NodeType.Class && member.DeclaringType.NodeType==NodeType.Class;
}
示例2: IsSpecInternal
private bool IsSpecInternal(Member member) {
return member.GetAttribute(SystemTypes.SpecInternalAttribute)!= null &&
this.currentType.DeclaringModule == member.DeclaringType.DeclaringModule;
}
示例3: switch
/*
* if (member == null || method == null) return false;
if (member is ParameterField) return true;
if (method.Flags == MethodFlags.CompilerControlled) return true; // comprehension, but what else?
switch ((((Method)method).Flags & MethodFlags.MethodAccessMask)){
case MethodFlags.Public:
return member.IsPublic ||
member.GetAttribute(SystemTypes.SpecPublicAttribute)!= null;
case MethodFlags.Family:
return member.IsPublic || member.IsFamily ||
member.GetAttribute(SystemTypes.SpecPublicAttribute)!= null || member.GetAttribute(SystemTypes.SpecProtectedAttribute)!= null;
case MethodFlags.Assembly:
return member.IsPublic || member.IsAssembly ||
member.GetAttribute(SystemTypes.SpecPublicAttribute)!= null || member.GetAttribute(SystemTypes.SpecInternalAttribute)!= null;
case MethodFlags.FamANDAssem:
return member.IsPublic || member.IsFamilyAndAssembly ||
member.GetAttribute(SystemTypes.SpecPublicAttribute)!=null ||
(member.GetAttribute(SystemTypes.SpecInternalAttribute)!=null && member.GetAttribute(SystemTypes.SpecProtectedAttribute) != null);
case MethodFlags.FamORAssem:
return member.IsPublic || member.IsFamily || member.IsFamilyOrAssembly || member.IsAssembly ||
member.GetAttribute(SystemTypes.SpecPublicAttribute)!=null || member.GetAttribute(SystemTypes.SpecInternalAttribute)!=null ||
member.GetAttribute(SystemTypes.SpecProtectedAttribute)!=null
;
case MethodFlags.Private:
return true;
*/
private bool IsSpecPublic(Member member) {
return member.GetAttribute(SystemTypes.SpecPublicAttribute)!= null;
}
示例4: AsAccessible
//member as accesible as the method in which it is used -- used for contracts
public virtual bool AsAccessible(Member member, Method method) {
if (member == null || method == null) return false;
if (member is ParameterField) return true;
if (method.Flags == MethodFlags.CompilerControlled) return true; // comprehension, but what else?
if (this.insideModifies) {
// no restrictions on what can be referred to within a modifies clause, at least
// not in terms of visibility.
return true;
}
// Relaxing the rules: for postconditions allow anything that all implementations of the
// method have access to.
if (this.insideEnsures) {
// if this method is the only implementation, it can see everything
if (!method.IsVirtual || method.DeclaringType.IsSealed || method.IsFinal)
return true;
// virtual methods can have other implementations in subtypes.
// Private fields are not allowed.
// Internal fields (that are not *also* protected) are allowed only if the method
// is not visible outside of the assembly.
// Everything else is allowed.
if (member.GetAttribute(SystemTypes.SpecPublicAttribute)== null
&&
(member.IsPrivate || (member.IsAssembly && !member.IsFamily && method.IsVisibleOutsideAssembly)))
return false;
return true;
}
switch ((((Method)method).Flags & MethodFlags.MethodAccessMask)) {
case MethodFlags.Public:
return member.IsPublic ||
member.GetAttribute(SystemTypes.SpecPublicAttribute)!= null;
case MethodFlags.Family:
return member.IsPublic || member.IsFamily || member.IsFamilyOrAssembly ||
member.GetAttribute(SystemTypes.SpecPublicAttribute)!= null || member.GetAttribute(SystemTypes.SpecProtectedAttribute)!= null;
case MethodFlags.Assembly:
return member.IsPublic || member.IsAssembly || member.IsFamilyOrAssembly ||
member.GetAttribute(SystemTypes.SpecPublicAttribute)!= null || member.GetAttribute(SystemTypes.SpecInternalAttribute)!= null;
case MethodFlags.FamANDAssem:
return member.IsPublic || member.IsFamilyAndAssembly ||
member.GetAttribute(SystemTypes.SpecPublicAttribute)!=null ||
(member.GetAttribute(SystemTypes.SpecInternalAttribute)!=null && member.GetAttribute(SystemTypes.SpecProtectedAttribute) != null);
case MethodFlags.FamORAssem:
return member.IsPublic || member.IsFamily || member.IsFamilyOrAssembly || member.IsAssembly ||
member.GetAttribute(SystemTypes.SpecPublicAttribute)!=null || member.GetAttribute(SystemTypes.SpecInternalAttribute)!=null ||
member.GetAttribute(SystemTypes.SpecProtectedAttribute)!=null
;
case MethodFlags.Private:
return true;
}
Debug.Assert(false);
return false;
}
示例5: 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;
}
示例6: IsInInvariantAllowed
//member as accesible as the method in which it is used -- used for contracts
public virtual bool IsInInvariantAllowed(Member member, Method method) {
if (member == null || method == null) return false;
if (member is ParameterField) return true;
switch ((((Method)method).Flags & MethodFlags.MethodAccessMask)) {
case MethodFlags.Public:
return member.IsPublic ||
member.GetAttribute(SystemTypes.SpecPublicAttribute)!= null;
case MethodFlags.Family:
return member.IsPublic || member.IsFamily ||
member.GetAttribute(SystemTypes.SpecPublicAttribute)!= null || member.GetAttribute(SystemTypes.SpecProtectedAttribute)!= null;
case MethodFlags.Assembly:
return member.IsPublic || member.IsAssembly ||
member.GetAttribute(SystemTypes.SpecPublicAttribute)!= null || member.GetAttribute(SystemTypes.SpecInternalAttribute)!= null;
case MethodFlags.FamANDAssem:
return member.IsPublic || member.IsFamilyAndAssembly ||
member.GetAttribute(SystemTypes.SpecPublicAttribute)!=null ||
(member.GetAttribute(SystemTypes.SpecInternalAttribute)!=null && member.GetAttribute(SystemTypes.SpecProtectedAttribute) != null);
case MethodFlags.FamORAssem:
return member.IsPublic || member.IsFamily || member.IsFamilyOrAssembly || member.IsAssembly ||
member.GetAttribute(SystemTypes.SpecPublicAttribute)!=null || member.GetAttribute(SystemTypes.SpecInternalAttribute)!=null ||
member.GetAttribute(SystemTypes.SpecProtectedAttribute)!=null
;
case MethodFlags.Private:
return member.IsPrivate;
}
Debug.Assert(false);
return false;
}
示例7: IsCompilerGenerated
internal static bool IsCompilerGenerated(Member m) {
if (m == null) return false;
if (m.GetAttribute(compilerGeneratedAttributeNode) != null) return true;
TypeNode t = m.DeclaringType;
while (t != null) {
if (IsCompilerGenerated(t)) return true;
t = t.DeclaringType;
}
return false;
}