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


C# ITypeResolveContext.WithCurrentMember方法代码示例

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


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

示例1: UnknownCodeContext

        public UnknownCodeContext(ICompilation compilation, IUnresolvedFile file, TextLocation location)
            : this(compilation)
        {
            var curDef = file.GetInnermostTypeDefinition (location);
            if (curDef != null) {
                var resolvedDef = curDef.Resolve (context).GetDefinition ();
                if (resolvedDef != null) {
                    context = context.WithCurrentTypeDefinition (resolvedDef);

                    var curMember = resolvedDef.Members.FirstOrDefault (m => m.Region.FileName == file.FileName && m.Region.Begin <= location && location < m.BodyRegion.End);
                    if (curMember != null)
                        context = context.WithCurrentMember (curMember);
                }
            }
        }
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:15,代码来源:UnknownCodeContext.cs

示例2: Resolve

		public static IMember Resolve(ITypeResolveContext context,
		                              EntityType entityType,
		                              string name,
		                              ITypeReference explicitInterfaceTypeReference = null,
		                              IList<string> typeParameterNames = null,
		                              IList<ITypeReference> parameterTypeReferences = null)
		{
			if (context.CurrentTypeDefinition == null)
				return null;
			if (parameterTypeReferences == null)
				parameterTypeReferences = EmptyList<ITypeReference>.Instance;
			if (typeParameterNames == null || typeParameterNames.Count == 0) {
				// non-generic member
				// In this case, we can simply resolve the parameter types in the given context
				var parameterTypes = parameterTypeReferences.Resolve(context);
				if (explicitInterfaceTypeReference == null) {
					foreach (IMember member in context.CurrentTypeDefinition.Members) {
						if (member.IsExplicitInterfaceImplementation)
							continue;
						if (IsNonGenericMatch(member, entityType, name, parameterTypes))
							return member;
					}
				} else {
					IType explicitInterfaceType = explicitInterfaceTypeReference.Resolve(context);
					foreach (IMember member in context.CurrentTypeDefinition.Members) {
						if (!member.IsExplicitInterfaceImplementation)
							continue;
						if (member.ImplementedInterfaceMembers.Count != 1)
							continue;
						if (IsNonGenericMatch(member, entityType, name, parameterTypes)) {
							if (explicitInterfaceType.Equals(member.ImplementedInterfaceMembers[0].DeclaringType))
								return member;
						}
					}
				}
			} else {
				// generic member
				// In this case, we must specify the correct context for resolving the parameter types
				foreach (IMethod method in context.CurrentTypeDefinition.Methods) {
					if (method.EntityType != entityType)
						continue;
					if (method.Name != name)
						continue;
					if (method.Parameters.Count != parameterTypeReferences.Count)
						continue;
					// Compare type parameter count and names:
					if (!typeParameterNames.SequenceEqual(method.TypeParameters.Select(tp => tp.Name)))
						continue;
					// Once we know the type parameter names are fitting, we can resolve the
					// type references in the context of the method:
					var contextForMethod = context.WithCurrentMember(method);
					var parameterTypes = parameterTypeReferences.Resolve(contextForMethod);
					if (!IsParameterTypeMatch(method, parameterTypes))
						continue;
					if (explicitInterfaceTypeReference == null) {
						if (!method.IsExplicitInterfaceImplementation)
							return method;
					} else if (method.IsExplicitInterfaceImplementation && method.ImplementedInterfaceMembers.Count == 1) {
						IType explicitInterfaceType = explicitInterfaceTypeReference.Resolve(contextForMethod);
						if (explicitInterfaceType.Equals(method.ImplementedInterfaceMembers[0].DeclaringType))
							return method;
					}
				}
			}
			return null;
		}
开发者ID:adisik,项目名称:simple-assembly-explorer,代码行数:66,代码来源:AbstractUnresolvedMember.cs

示例3: AbstractResolvedMember

		protected AbstractResolvedMember(IUnresolvedMember unresolved, ITypeResolveContext parentContext)
			: base(unresolved, parentContext)
		{
			this.unresolved = unresolved;
			this.context = parentContext.WithCurrentMember(this);
		}
开发者ID:Netring,项目名称:ILSpy,代码行数:6,代码来源:AbstractResolvedMember.cs


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