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


C# ITypeReference.Resolve方法代码示例

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


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

示例1: Substitute

		internal static ITypeReference Substitute(ITypeReference type, TypeVisitor substitution, ITypeResolveContext context)
		{
			if (substitution == null)
				return type;
			if (context != null)
				return type.Resolve(context).AcceptVisitor(substitution);
			else
				return SubstitutionTypeReference.Create(type, substitution);
		}
开发者ID:jiguixin,项目名称:ILSpy,代码行数:9,代码来源:SpecializedMember.cs

示例2: IsPersistent

 bool IsPersistent(ITypeReference type)
 {
     while (type != null)
     {
         ITypeDeclaration decl = type.Resolve();
         if (decl != null)
         {
             if (decl.Namespace == "Perst" && decl.Name == "Persistent")
             {
                 return true;
             }
             type = decl.BaseType;
         }
         else
         {
             break;
         }
     }
     return false;
 }
开发者ID:yan122725529,项目名称:TripRobot.Crawler,代码行数:20,代码来源:PerstAddin.cs

示例3: 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

示例4: Type

        public TypeInfo Type(ITypeReference typeReference)
        {
            if (typeReference == null)
            {
                return null;
            }

            var typeDeclaration = typeReference.Resolve();
            return Type(typeDeclaration);
        }
开发者ID:GREYFOXRGR,项目名称:AssemblyVisualizer,代码行数:10,代码来源:Converter.cs

示例5: AppendTypeName

		static void AppendTypeName(StringBuilder b, ITypeReference type, ITypeResolveContext context)
		{
			IType resolvedType = type as IType;
			if (resolvedType != null) {
				AppendTypeName(b, resolvedType);
				return;
			}
			GetClassTypeReference gctr = type as GetClassTypeReference;
			if (gctr != null) {
				if (!string.IsNullOrEmpty(gctr.Namespace)) {
					b.Append(gctr.Namespace);
					b.Append('.');
				}
				b.Append(gctr.Name);
				if (gctr.TypeParameterCount > 0) {
					b.Append('`');
					b.Append(gctr.TypeParameterCount);
				}
				return;
			}
			NestedTypeReference ntr = type as NestedTypeReference;
			if (ntr != null) {
				AppendTypeName(b, ntr.DeclaringTypeReference, context);
				b.Append('.');
				b.Append(ntr.Name);
				if (ntr.AdditionalTypeParameterCount > 0) {
					b.Append('`');
					b.Append(ntr.AdditionalTypeParameterCount);
				}
				return;
			}
			ParameterizedTypeReference pt = type as ParameterizedTypeReference;
			if (pt != null && IsGetClassTypeReference(pt.GenericType)) {
				AppendParameterizedTypeName(b, pt.GenericType, pt.TypeArguments, context);
				return;
			}
			ArrayTypeReference array = type as ArrayTypeReference;
			if (array != null) {
				AppendTypeName(b, array.ElementType, context);
				b.Append('[');
				if (array.Dimensions > 1) {
					for (int i = 0; i < array.Dimensions; i++) {
						if (i > 0) b.Append(',');
						b.Append("0:");
					}
				}
				b.Append(']');
				return;
			}
			PointerTypeReference ptr = type as PointerTypeReference;
			if (ptr != null) {
				AppendTypeName(b, ptr.ElementType, context);
				b.Append('*');
				return;
			}
			ByReferenceTypeReference brtr = type as ByReferenceTypeReference;
			if (brtr != null) {
				AppendTypeName(b, brtr.ElementType, context);
				b.Append('@');
				return;
			}
			if (context == null)
				b.Append('?');
			else
				AppendTypeName(b, type.Resolve(context));
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:66,代码来源:IDStringProvider.cs

示例6: IsValueType

        public static bool IsValueType(ITypeReference value)
        {
            if (value != null)
            {
                ITypeDeclaration typeDeclaration = value.Resolve();
                if (typeDeclaration == null)
                {
                    return false;
                }

                // TODO
                ITypeReference baseType = typeDeclaration.BaseType;
                return ((baseType != null) && ((baseType.Name == "ValueType") || (baseType.Name == "Enum")) && (baseType.Namespace == "System"));
            }

            return false;
        }
开发者ID:lzybkr,项目名称:CppCliReflector,代码行数:17,代码来源:Helper.cs

示例7: IsDelegate

        public static bool IsDelegate(ITypeReference value)
        {
            if (value != null)
            {
                // TODO
                if ((value.Name == "MulticastDelegate") && (value.Namespace == "System"))
                {
                    return false;
                }

                ITypeDeclaration typeDeclaration = value.Resolve();
                if (typeDeclaration == null)
                {
                    return false;
                }

                ITypeReference baseType = typeDeclaration.BaseType;
                return ((baseType != null) && (baseType.Namespace == "System") && ((baseType.Name == "MulticastDelegate") || (baseType.Name == "Delegate")) && (baseType.Namespace == "System"));
            }

            return false;
        }
开发者ID:lzybkr,项目名称:CppCliReflector,代码行数:22,代码来源:Helper.cs

示例8: Resolve

		ITypeDefinition Resolve (TypeSystemService.ProjectContentWrapper dom, ITypeReference reference)
		{
			return reference.Resolve (dom.Compilation).GetDefinition ();
		}
开发者ID:sparek,项目名称:monodevelop,代码行数:4,代码来源:NSObjectInfoService.cs

示例9: CreateTypeReferenceExpression

		private JsTypeReferenceExpression CreateTypeReferenceExpression(ITypeReference tr) {
			return new JsTypeReferenceExpression(tr.Resolve(_compilation).GetDefinition());
		}
开发者ID:kumar0190,项目名称:SaltarelleCompiler,代码行数:3,代码来源:RuntimeLibrary.cs

示例10: ConvertTypeReference

		public AstType ConvertTypeReference(ITypeReference typeRef)
		{
			ArrayTypeReference array = typeRef as ArrayTypeReference;
			if (array != null) {
				return ConvertTypeReference(array.ElementType).MakeArrayType(array.Dimensions);
			}
			PointerTypeReference pointer = typeRef as PointerTypeReference;
			if (pointer != null) {
				return ConvertTypeReference(pointer.ElementType).MakePointerType();
			}
			ByReferenceType brt = typeRef as ByReferenceType;
			if (brt != null) {
				return ConvertTypeReference(brt.ElementType);
			}
			
			IType type = typeRef.Resolve(context);
			if (type.Kind != TypeKind.Unknown)
				return ConvertType(type);
			// Unknown type, let's try if we can find an appropriate type
			// (anything is better than displaying a question mark)
			KnownTypeReference knownType = typeRef as KnownTypeReference;
			if (knownType != null) {
				string keyword = ReflectionHelper.GetCSharpNameByTypeCode(knownType.TypeCode);
				if (keyword != null)
					return new PrimitiveType(keyword);
			}
			SimpleTypeOrNamespaceReference str = typeRef as SimpleTypeOrNamespaceReference;
			if (str != null) {
				return new SimpleType(str.Identifier, str.TypeArguments.Select(ConvertTypeReference));
			}
			MemberTypeOrNamespaceReference mtr = typeRef as MemberTypeOrNamespaceReference;
			if (mtr != null) {
				return new MemberType(ConvertTypeReference(mtr.Target), mtr.Identifier, mtr.TypeArguments.Select(ConvertTypeReference)) {
					IsDoubleColon = mtr.Target is AliasNamespaceReference
				};
			}
			AliasNamespaceReference alias = typeRef as AliasNamespaceReference;
			if (alias != null) {
				return new SimpleType(alias.Identifier);
			}
			// Unknown type reference that couldn't be resolved
			return new SimpleType("?");
		}
开发者ID:jiguixin,项目名称:ILSpy,代码行数:43,代码来源:TypeSystemAstBuilder.cs

示例11: TypeToString

		string TypeToString(ITypeReference type, ITypeDefinition currentTypeDef = null)
		{
			var builder = CreateBuilder(currentTypeDef);
			IType resolvedType = type.Resolve(ctx);
			AstType node = builder.ConvertType(resolvedType);
			return node.ToString();
		}
开发者ID:sbeparey,项目名称:ILSpy,代码行数:7,代码来源:TypeSystemAstBuilderTests.cs

示例12: IsValueType

    /// <summary>
    /// Determines whether the specified value is a value type.
    /// </summary>
    /// <param name="value">The type reference value.</param>
    /// <returns>
    ///   <c>true</c> if the specified value is a value type; otherwise, <c>false</c>.
    /// </returns>
    internal static bool IsValueType(ITypeReference value)
    {
      if (value != null)
      {
        ITypeDeclaration typeDeclaration = value.Resolve();
        if (typeDeclaration == null)
        {
          return false;
        }

        return typeDeclaration.ValueType;
      }

      return false;
    }
开发者ID:WrongDog,项目名称:Sequence,代码行数:22,代码来源:ReflectorHelper.cs

示例13: IsEnumeration

    /// <summary>
    /// Determines whether the specified value is enumeration.
    /// </summary>
    /// <param name="value">The type reference value.</param>
    /// <returns>
    ///   <c>true</c> if the specified value is enumeration; otherwise, <c>false</c>.
    /// </returns>
    internal static bool IsEnumeration(ITypeReference value)
    {
      if (value != null)
      {
        ITypeDeclaration typeDeclaration = value.Resolve();
        if (typeDeclaration == null)
        {
          return false;
        }

        ITypeReference baseType = typeDeclaration.BaseType;
        return baseType != null && baseType.Name == "Enum" && baseType.Namespace == "System";
      }

      return false;
    }
开发者ID:WrongDog,项目名称:Sequence,代码行数:23,代码来源:ReflectorHelper.cs

示例14: IsDelegate

    /// <summary>
    /// Determines whether the specified value is delegate.
    /// </summary>
    /// <param name="value">The type reference value.</param>
    /// <returns>
    ///  <c>true</c> if the specified value is delegate; otherwise, <c>false</c>.
    /// </returns>
    internal static bool IsDelegate(ITypeReference value)
    {
      if (value != null)
      {
        if ((value.Name == "MulticastDelegate") && (value.Namespace == "System"))
        {
          return false;
        }

        ITypeDeclaration typeDeclaration = value.Resolve();
        if (typeDeclaration == null)
        {
          return false;
        }

        ITypeReference baseType = typeDeclaration.BaseType;
        return baseType != null && baseType.Namespace == "System" && (baseType.Name == "MulticastDelegate" || baseType.Name == "Delegate");
      }

      return false;
    }
开发者ID:WrongDog,项目名称:Sequence,代码行数:28,代码来源:ReflectorHelper.cs

示例15: AddAdditionalType

    /// <summary>
    /// Adds the type of the additional.
    /// </summary>
    /// <param name="typeReference">The type reference.</param>
    private void AddAdditionalType(ITypeReference typeReference)
    {
      if (this.TypeDataList.Find(typeInfo => string.Compare(typeInfo.TypeName, typeReference.Name, StringComparison.Ordinal) == 0) != null)
      {
        // Type already added
        Logger.Current.Info("The type is already in the additional list..." + typeReference.ToString());
        return;
      }

      this.AdditionalLoadList.Add(typeReference.Resolve());
    }
开发者ID:WrongDog,项目名称:Sequence,代码行数:15,代码来源:ClassData.cs


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