当前位置: 首页>>代码示例>>C#>>正文


C# IType.GetNestedTypes方法代码示例

本文整理汇总了C#中IType.GetNestedTypes方法的典型用法代码示例。如果您正苦于以下问题:C# IType.GetNestedTypes方法的具体用法?C# IType.GetNestedTypes怎么用?C# IType.GetNestedTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IType的用法示例。


在下文中一共展示了IType.GetNestedTypes方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ParseTypeToModel

 private void ParseTypeToModel(SDType sdType, IType type)
 {
     sdType.IsProjectStranger = false;
     AddParsedTypeArguments(sdType, type.TypeArguments);
     AddParsedTypeParameters(sdType, type.GetDefinition().TypeParameters);
     AddParsedNestedTypes(sdType, type.GetNestedTypes());
     AddParsedBaseTypes(sdType, type.DirectBaseTypes);
     AddParsedInterfaces(sdType, type.DirectBaseTypes);            
     AddParsedProperties(sdType, type);
     AddParsedFields(sdType, type);
     AddParsedConstructorsAndMethods(sdType, type);
     AddParsedEvents(sdType, type);
 }
开发者ID:llenroc,项目名称:sharpDox,代码行数:13,代码来源:TypeParser.cs

示例2: Lookup

		/// <summary>
		/// Performs a member lookup.
		/// </summary>
		public ResolveResult Lookup(IType type, string name, IList<IType> typeArguments, bool isInvocation)
		{
			int typeArgumentCount = typeArguments.Count;
			
			List<IType> types = new List<IType>();
			List<IMember> members = new List<IMember>();
			if (!isInvocation) {
				// Consider nested types only if it's not an invocation. The type parameter count must match in this case.
				Predicate<ITypeDefinition> typeFilter = delegate (ITypeDefinition d) {
					return d.TypeParameterCount == typeArgumentCount && d.Name == name && IsAccessible(d, true);
				};
				types.AddRange(type.GetNestedTypes(context, typeFilter));
			}
			
			bool allowProtectedAccess = IsProtectedAccessAllowed(type);
			
			if (typeArgumentCount == 0) {
				Predicate<IMember> memberFilter = delegate(IMember member) {
					return !member.IsOverride && member.Name == name && IsAccessible(member, allowProtectedAccess);
				};
				members.AddRange(type.GetMethods(context, memberFilter.SafeCast<IMember, IMethod>()).SafeCast<IMethod, IMember>());
				members.AddRange(type.GetProperties(context, memberFilter.SafeCast<IMember, IProperty>()).SafeCast<IProperty, IMember>());
				members.AddRange(type.GetFields(context, memberFilter.SafeCast<IMember, IField>()).SafeCast<IField, IMember>());
				members.AddRange(type.GetEvents(context, memberFilter.SafeCast<IMember, IEvent>()).SafeCast<IEvent, IMember>());
				if (isInvocation)
					members.RemoveAll(m => !IsInvocable(m, context));
			} else {
				// No need to check for isInvocation/isInvocable here:
				// we filter out all non-methods
				Predicate<IMethod> memberFilter = delegate(IMethod method) {
					return method.TypeParameters.Count == typeArgumentCount
						&& !method.IsOverride && method.Name == name && IsAccessible(method, allowProtectedAccess);
				};
				members.AddRange(type.GetMethods(context, memberFilter).SafeCast<IMethod, IMember>());
			}
			
			// TODO: can't members also hide types?
			
			RemoveTypesHiddenByOtherTypes(types);
			// remove members hidden by types
			for (int i = 0; i < types.Count; i++) {
				ITypeDefinition d = GetDeclaringTypeDef(types[i]);
				if (d != null)
					members.RemoveAll(m => d.IsDerivedFrom(m.DeclaringTypeDefinition, context));
			}
			// remove members hidden by other members
			for (int i = members.Count - 1; i >= 0; i--) {
				ITypeDefinition d = members[i].DeclaringTypeDefinition;
				IMethod mi = members[i] as IMethod;
				// nested loop depends on the fact that the members of more derived classes appear later in the list
				for (int j = i + 1; j < members.Count; j++) {
					if (mi != null) {
						IMethod mj = members[j] as IMethod;
						if (mj != null && !ParameterListComparer.Instance.Equals(mi, mj))
							continue;
					}
					ITypeDefinition s = members[j].DeclaringTypeDefinition;
					if (s != null && s != d && s.IsDerivedFrom(d, context)) {
						// members[j] hides members[i]
						members.RemoveAt(i);
						break;
					}
				}
			}
			// remove interface members hidden by class members
			if (type is ITypeParameter) {
				// this can happen only with type parameters
				for (int i = members.Count - 1; i >= 0; i--) {
					ITypeDefinition d = members[i].DeclaringTypeDefinition;
					if (d.ClassType != ClassType.Interface)
						continue;
					IMethod mi = members[i] as IMethod;
					for (int j = 0; j < members.Count; j++) {
						if (mi != null) {
							IMethod mj = members[j] as IMethod;
							if (mj != null && !ParameterListComparer.Instance.Equals(mi, mj))
								continue;
						}
						ITypeDefinition s = members[j].DeclaringTypeDefinition;
						if (s != null && IsNonInterfaceType(s)) {
							// members[j] hides members[i]
							members.RemoveAt(i);
							break;
						}
					}
				}
			}
			
			if (types.Count > 0) {
				bool isAmbiguous = !(types.Count == 1 && members.Count == 0);
				return CreateTypeResolveResult(types[0], isAmbiguous, typeArguments);
			}
			if (members.Count == 0)
				return new UnknownMemberResolveResult(type, name, typeArguments);
			IMember firstNonMethod = members.FirstOrDefault(m => !(m is IMethod));
			if (members.Count == 1 && firstNonMethod != null)
				return new MemberResolveResult(firstNonMethod, context);
//.........这里部分代码省略.........
开发者ID:constructor-igor,项目名称:cudafy,代码行数:101,代码来源:MemberLookup.cs

示例3: LookupType

		public ResolveResult LookupType(IType declaringType, string name, IList<IType> typeArguments)
		{
			int typeArgumentCount = typeArguments.Count;
			Predicate<ITypeDefinition> typeFilter = delegate (ITypeDefinition d) {
				return d.TypeParameterCount == typeArgumentCount && d.Name == name && IsAccessible(d, true);
			};
			List<IType> types = declaringType.GetNestedTypes(context, typeFilter).ToList();
			RemoveTypesHiddenByOtherTypes(types);
			if (types.Count > 0)
				return CreateTypeResolveResult(types[0], types.Count > 1, typeArguments);
			else
				return new UnknownMemberResolveResult(declaringType, name, typeArguments);
		}
开发者ID:constructor-igor,项目名称:cudafy,代码行数:13,代码来源:MemberLookup.cs

示例4: SelfAndNested

 private IEnumerable<IType> SelfAndNested(IType type)
 {
     yield return type;
     foreach (var x in type.GetNestedTypes(options: GetMemberOptions.IgnoreInheritedMembers).SelectMany(c => SelfAndNested(c))) {
         yield return x;
     }
 }
开发者ID:jack128,项目名称:SaltarelleCompiler,代码行数:7,代码来源:Compiler.cs

示例5: EnumAllNestedTypes

 /// <summary>
 /// </summary>
 /// <param name="type">
 /// </param>
 /// <returns>
 /// </returns>
 private static IEnumerable<IType> EnumAllNestedTypes(IType type)
 {
     foreach (var nestedType in type.GetNestedTypes())
     {
         yield return nestedType;
         foreach (var subNestedType in EnumAllNestedTypes(nestedType))
         {
             yield return subNestedType;
         }
     }
 }
开发者ID:SperoSophia,项目名称:il2bc,代码行数:17,代码来源:IlReader.cs


注:本文中的IType.GetNestedTypes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。