本文整理汇总了C#中System.Compiler.Member类的典型用法代码示例。如果您正苦于以下问题:C# Member类的具体用法?C# Member怎么用?C# Member使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Member类属于System.Compiler命名空间,在下文中一共展示了Member类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsExposedMember
public bool? IsExposedMember(Member member) {
if (member.Name.Name == name) {
return (exposed);
} else {
return (null);
}
}
示例2: VisitMemberBinding
/// <summary>
/// Checks for less-than-visible member references in an expression.
/// </summary>
public override void VisitMemberBinding(MemberBinding binding)
{
if (binding == null) return;
Member mem = binding.BoundMember;
if (mem != null)
{
Field f = mem as Field;
bool specPublic = false;
if (f != null)
{
specPublic = IsSpecPublic(f);
}
if (!specPublic && !HelperMethods.IsCompilerGenerated(mem))
{
// F: It seems there is some type-state like invariant here justifying why this.AsThisMemeber != null
Contract.Assume(this.AsThisMember != null);
if (!HelperMethods.IsReferenceAsVisibleAs(mem, this.AsThisMember))
{
this.memberInErrorFound = mem;
return;
}
}
}
base.VisitMemberBinding(binding);
}
示例3: IsExposedMember
public override bool IsExposedMember(Member member) {
// member of delegates are not exposed
TypeNode type = member.DeclaringType;
if (type.NodeType == NodeType.DelegateNode) return (false);
// accessor methods for properties and events are not exposed
if (member.IsSpecialName && (member.NodeType == NodeType.Method)) {
string name = member.Name.Name;
if (NameContains(name, "get_")) return (false);
if (NameContains(name, "set_")) return (false);
if (NameContains(name, "add_")) return (false);
if (NameContains(name, "remove_")) return (false);
if (NameContains(name, "raise_")) return (false);
}
// the value field of enumerations is not exposed
if (member.IsSpecialName && (type.NodeType == NodeType.EnumNode) && (member.NodeType == NodeType.Field)) {
string name = member.Name.Name;
if (name == "value__") return (false);
}
// members marked as compiler-generated are not exposed
if (ListContainsAttribute(member.Attributes, "System.Runtime.CompilerServices.CompilerGeneratedAttribute")) {
return (false);
}
// okay, passed all tests, so member is exposed
return (base.IsExposedMember(member));
}
示例4: IsExposedApi
// exposure logic for artibrary APIs
// call the appropriate particular exposure logic
public virtual bool IsExposedApi(Member api) {
Namespace space = api as Namespace;
if (space != null) return (IsExposedNamespace(space));
TypeNode type = api as TypeNode;
if (type != null) return (IsExposedType(type));
return (IsExposedMember(api));
}
示例5: CheckModelfieldAdmissibility
public void CheckModelfieldAdmissibility(ModelfieldContract mfC) {
this.DeclaringMfC = mfC;
this.DeclaringMember = mfC.Modelfield;
if (this.DeclaringMember is Property)
this.DeclaringMember = (this.DeclaringMember as Property).Getter; //references to the modelfield have been resolved as bindings to this getter
foreach (Expression satExpr in mfC.SatisfiesList) {
StateStack = new System.Collections.Stack();
ResetCurrentState();
this.VisitExpression(satExpr);
}
}
示例6: GetApiName
public virtual string GetApiName(Member api) {
Namespace space = api as Namespace;
if (space != null) return (GetNamespaceName(space));
TypeNode type = api as TypeNode;
if (type != null) return (GetTypeName(type));
return (GetMemberName(api));
}
示例7: VisitMemberReference
public virtual Member VisitMemberReference(Member member)
{
if(member == null)
return null;
TypeNode specializedType = this.VisitTypeReference(member.DeclaringType);
if(specializedType == member.DeclaringType || specializedType == null)
return member;
return Specializer.GetCorrespondingMember(member, specializedType);
}
示例8: IsExposedMember
public bool? IsExposedMember(Member member) {
//Console.WriteLine("DEBUG: typeFilter.IsExposedMember");
TypeNode type = ReflectionUtilities.GetTemplateType(member.DeclaringType);
if (IsExposedType(type) != null) {
foreach (MemberFilter memberFilter in memberFilters) {
bool? result = memberFilter.IsExposedMember(member);
if (result != null) return (result);
}
return (exposed); //return the type's exposed setting
} else {
return (null);
}
}
示例9: IsExposedMember
//=====================================================================
/// <summary>
/// Check to see if the member is exposed or not by this entry
/// </summary>
/// <param name="member">The member to check</param>
/// <returns>Null if the member is not represented by this entry, true if it is and it is exposed or
/// false if it is and it is not exposed.</returns>
public bool? IsExposedMember(Member member)
{
// Try for an exact match first
if(member.Name.Name == name)
return exposed;
// !EFW - If the member name contains "<" and our name contains "{", this is probably a
// generic using the XML comments syntax member ID so try for a match that way too.
if(member.Name.Name.IndexOf('<') != -1 && name.IndexOf('{') != -1 &&
member.Name.Name.Replace('<', '{').Replace('>', '}') == name)
return exposed;
return null;
}
示例10: GetName
private static string GetName(Member entity) {
using (TextWriter writer = new StringWriter()) {
TypeNode type = entity as TypeNode;
if (type != null) {
writer.Write("T:");
WriteType(type, writer);
return (writer.ToString());
}
switch (entity.NodeType) {
case NodeType.Namespace:
writer.Write("N:");
WriteNamespace(entity as Namespace, writer);
break;
case NodeType.Field:
writer.Write("F:");
WriteField(entity as Field, writer);
break;
case NodeType.Property:
writer.Write("P:");
WriteProperty(entity as Property, writer);
break;
case NodeType.Method:
writer.Write("M:");
WriteMethod(entity as Method, writer);
break;
case NodeType.InstanceInitializer:
writer.Write("M:");
WriteConstructor(entity as InstanceInitializer, writer);
break;
case NodeType.StaticInitializer:
writer.Write("M:");
WriteStaticConstructor(entity as StaticInitializer, writer);
break;
case NodeType.Event:
writer.Write("E:");
WriteEvent(entity as Event, writer);
break;
}
return (writer.ToString());
}
}
示例11: IsExposedMember
public override bool IsExposedMember(Member member)
{
if (member == null) throw new ArgumentNullException("member");
TypeNode type = member.DeclaringType;
// if the member isn't visible, we certainly won't expose it...
if (!member.IsVisibleOutsideAssembly && !(protectedSealedVisible && type.IsSealed && (member.IsFamily || member.IsFamilyOrAssembly)))
return (false);
// ...but there are also some visible members we won't expose.
// member of delegates are not exposed
if (type.NodeType == NodeType.DelegateNode) return (false);
// accessor methods for properties and events are not exposed
if (member.IsSpecialName && (member.NodeType == NodeType.Method))
{
string name = member.Name.Name;
if (NameContains(name, "get_")) return (false);
if (NameContains(name, "set_")) return (false);
if (NameContains(name, "add_")) return (false);
if (NameContains(name, "remove_")) return (false);
if (NameContains(name, "raise_")) return (false);
}
// the value field of enumerations is not exposed
if (member.IsSpecialName && (type.NodeType == NodeType.EnumNode) && (member.NodeType == NodeType.Field))
{
string name = member.Name.Name;
if (name == "value__") return (false);
}
// protected members of sealed types are not exposed
// change of plan -- yes they are
// if (type.IsSealed && (member.IsFamily || member.IsFamilyOrAssembly)) return(false);
// One more test to deal with a wierd case: a private method is an explicit implementation for
// a property accessor, but is not marked with the special name flag. To find these, test for
// the accessibility of the methods they implement
if (member.IsPrivate && member.NodeType == NodeType.Method)
{
Method method = (Method)member;
MethodList implements = method.ImplementedInterfaceMethods;
if ((implements.Count > 0) && (!IsExposedMember(implements[0]))) return (false);
}
// okay, passed all tests, the member is exposed as long as the filters allow it
return (base.IsExposedMember(member));
}
示例12: IsExposedMember
public bool? IsExposedMember(Member member) {
//Console.WriteLine("DEBUG: namespaceFilter.isExposedMemeber");
TypeNode type = ReflectionUtilities.GetTemplateType(member.DeclaringType);
Namespace space = ReflectionUtilities.GetNamespace(type);
if (IsExposedNamespace(space) != null) {
foreach (TypeFilter typeFilter in typeFilters) {
bool? result = typeFilter.IsExposedMember(member);
if (result != null) return (result);
}
//no filters matched this method, check if the type is exposed
bool? typeIsExposed = IsExposedType(type);
if (typeIsExposed != null) return typeIsExposed;
return (exposed); //if the namespace is exposed
} else {
return (null);
}
}
示例13: GetTemplateMember
public static Member GetTemplateMember(Member member) {
if (member == null) throw new ArgumentNullException("member");
// if the containing type isn't generic, the member is the template member
TypeNode type = member.DeclaringType;
if (!type.IsGeneric) return (member);
// if the containing type isn't specialized, the member is the template member
if (!IsSpecialized(type)) return (member);
// get the template type, and look for members with the same name
TypeNode template = ReflectionUtilities.GetTemplateType(member.DeclaringType);
Identifier name = member.Name;
MemberList candidates = template.GetMembersNamed(name);
// if no candidates, say so (this shouldn't happen)
if (candidates.Count == 0) throw new InvalidOperationException("No members in the template had the name found in the specialization. This is not possible, but apparently it happened.");
// if only one candidate, return it
if (candidates.Count == 1) return (candidates[0]);
// multiple candidates, so now we need to compare parameters
ParameterList parameters = GetParameters(member);
for (int i = 0; i < candidates.Count; i++) {
Member candidate = candidates[i];
// candidate must be same kind of node
if (candidate.NodeType != member.NodeType) continue;
// if parameters match, this is the one
if (ParametersMatch(parameters, GetParameters(candidate))) return (candidate);
}
Console.WriteLine(member.DeclaringType.FullName);
Console.WriteLine(member.FullName);
throw new InvalidOperationException("No members in the template matched the parameters of the specialization. This is not possible.");
}
示例14: GetMemberName
/// <inheritdoc />
public override string GetMemberName(Member member)
{
StringBuilder sb = new StringBuilder();
switch(member.NodeType)
{
case NodeType.Field:
sb.Append("F:");
WriteField((Field)member, sb);
break;
case NodeType.Property:
sb.Append("P:");
WriteProperty((Property)member, sb);
break;
case NodeType.Event:
sb.Append("E:");
WriteEvent((Event)member, sb);
break;
case NodeType.Method:
sb.Append("M:");
WriteMethod((Method)member, sb);
break;
case NodeType.InstanceInitializer:
sb.Append("M:");
WriteConstructor((InstanceInitializer)member, sb);
break;
case NodeType.StaticInitializer:
sb.Append("M:");
WriteStaticConstructor((StaticInitializer)member, sb);
break;
}
return sb.ToString();
}
示例15: GetMemberName
public override string GetMemberName(Member member) {
using (TextWriter writer = new StringWriter()) {
switch (member.NodeType) {
case NodeType.Field:
writer.Write("F:");
WriteField((Field)member, writer);
break;
case NodeType.Property:
writer.Write("P:");
WriteProperty((Property)member, writer);
break;
case NodeType.Method:
writer.Write("M:");
WriteMethod((Method)member, writer);
break;
case NodeType.InstanceInitializer:
writer.Write("M:");
WriteConstructor((InstanceInitializer)member, writer);
break;
case NodeType.StaticInitializer:
writer.Write("M:");
WriteStaticConstructor((StaticInitializer)member, writer);
break;
case NodeType.Event:
writer.Write("E:");
WriteEvent((Event)member, writer);
break;
}
return (writer.ToString());
}
}