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


C# IGenericContext类代码示例

本文整理汇总了C#中IGenericContext的典型用法代码示例。如果您正苦于以下问题:C# IGenericContext类的具体用法?C# IGenericContext怎么用?C# IGenericContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: ResolveMethod

        public IMethod ResolveMethod(int token, IGenericContext genericContext)
        {
            if (this.tokenResolutions != null && this.tokenResolutions.Count >= token)
            {
                return this.tokenResolutions[token - 1] as IMethod;
            }

            return this.method.Module.ResolveMethod(token, genericContext);
        }
开发者ID:afrog33k,项目名称:csnative,代码行数:9,代码来源:SynthesizedModuleResolver.cs

示例2: ResolveType

        public IType ResolveType(int token, IGenericContext genericContext)
        {
            if (tokenResolutions != null && tokenResolutions.Count >= token)
            {
                return tokenResolutions[token - 1] as IType;
            }

            return this.method.Module.ResolveType(token, genericContext);
        }
开发者ID:SperoSophia,项目名称:il2bc,代码行数:9,代码来源:SynthesizedModuleResolver.cs

示例3: GetMethodBody

		internal MethodBody GetMethodBody(IGenericContext context)
		{
			if ((GetMethodImplementationFlags() & MethodImplAttributes.CodeTypeMask) != MethodImplAttributes.IL)
			{
				// method is not IL
				return null;
			}
			int rva = module.MethodDef.records[index].RVA;
			return rva == 0 ? null : new MethodBody(module, rva, context);
		}
开发者ID:ngraziano,项目名称:mono,代码行数:10,代码来源:Method.cs

示例4: ReadSig

		internal static FieldSignature ReadSig(ModuleReader module, ByteReader br, IGenericContext context)
		{
			if (br.ReadByte() != FIELD)
			{
				throw new BadImageFormatException();
			}
			CustomModifiers mods = CustomModifiers.Read(module, br, context);
			Type fieldType = ReadType(module, br, context);
			return new FieldSignature(fieldType, mods);
		}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:10,代码来源:FieldSignature.cs

示例5: ExceptionHandlingClause

		internal ExceptionHandlingClause(ModuleReader module, int flags, int tryOffset, int tryLength, int handlerOffset, int handlerLength, int classTokenOrfilterOffset, IGenericContext context)
		{
			this.flags = flags;
			this.tryOffset = tryOffset;
			this.tryLength = tryLength;
			this.handlerOffset = handlerOffset;
			this.handlerLength = handlerLength;
			this.catchType = flags == (int)ExceptionHandlingClauseOptions.Clause && classTokenOrfilterOffset != 0 ? module.ResolveType(classTokenOrfilterOffset, context) : null;
			this.filterOffset = flags == (int)ExceptionHandlingClauseOptions.Filter ? classTokenOrfilterOffset : 0;
		}
开发者ID:koush,项目名称:mono,代码行数:10,代码来源:ExceptionHandlingClause.cs

示例6: MetadataMethodAdapter

        /// <summary>
        /// </summary>
        /// <param name="methodDef">
        /// </param>
        /// <param name="genericContext">
        /// </param>
        internal MetadataMethodAdapter(MethodSymbol methodDef, IGenericContext genericContext)
            : this(methodDef)
        {
            this.GenericContext = genericContext;

            var peMethodSymbol = methodDef as PEMethodSymbol;
            if (peMethodSymbol != null)
            {
                this.Token = MetadataTokens.GetToken(peMethodSymbol.Handle);
            }
        }
开发者ID:SperoSophia,项目名称:il2bc,代码行数:17,代码来源:MetadataMethodAdapter.cs

示例7: ResolveField

        /// <summary>
        /// </summary>
        /// <param name="token">
        /// </param>
        /// <param name="genericContext">
        /// </param>
        /// <returns>
        /// </returns>
        /// <exception cref="KeyNotFoundException">
        /// </exception>
        public IField ResolveField(int token, IGenericContext genericContext)
        {
            var peModuleSymbol = this.moduleDef as PEModuleSymbol;

            var fieldHandle = MetadataTokens.Handle(token);

            var fieldSymbol = peModuleSymbol.GetMetadataDecoder(genericContext).GetSymbolForILToken(fieldHandle) as FieldSymbol;
            if (fieldSymbol != null)
            {
                return new MetadataFieldAdapter(SubstituteFieldSymbolIfNeeded(fieldSymbol, genericContext));
            }

            return null;
        }
开发者ID:afrog33k,项目名称:csnative,代码行数:24,代码来源:MetadataModuleAdapter.cs

示例8: ResolveMember

        /// <summary>
        /// </summary>
        /// <param name="token">
        /// </param>
        /// <param name="genericContext">
        /// </param>
        /// <returns>
        /// </returns>
        /// <exception cref="NotImplementedException">
        /// </exception>
        public IMember ResolveMember(int token, IGenericContext genericContext)
        {
            var peModuleSymbol = this.moduleDef as PEModuleSymbol;

            var methodHandle = MetadataTokens.Handle(token);

            var methodSymbol = peModuleSymbol.GetMetadataDecoder(genericContext).GetSymbolForILToken(methodHandle) as MethodSymbol;
            if (methodSymbol != null)
            {
                if (methodSymbol.MethodKind == MethodKind.Constructor)
                {
                    return new MetadataConstructorAdapter(SubstituteMethodSymbolIfNeeded(methodSymbol, genericContext));
                }

                return new MetadataMethodAdapter(SubstituteMethodSymbolIfNeeded(methodSymbol, genericContext));
            }

            throw new NotImplementedException();
        }
开发者ID:afrog33k,项目名称:csnative,代码行数:29,代码来源:MetadataModuleAdapter.cs

示例9: ReadGenericInst

		private static Type ReadGenericInst(ModuleReader module, ByteReader br, IGenericContext context)
		{
			Type type;
			switch (br.ReadByte())
			{
				case ELEMENT_TYPE_CLASS:
					type = ReadTypeDefOrRefEncoded(module, br, context).MarkNotValueType();
					break;
				case ELEMENT_TYPE_VALUETYPE:
					type = ReadTypeDefOrRefEncoded(module, br, context).MarkValueType();
					break;
				default:
					throw new BadImageFormatException();
			}
			if (!type.__IsMissing && !type.IsGenericTypeDefinition)
			{
				throw new BadImageFormatException();
			}
			int genArgCount = br.ReadCompressedInt();
			Type[] args = new Type[genArgCount];
			Type[][] reqmod = null;
			Type[][] optmod = null;
			for (int i = 0; i < genArgCount; i++)
			{
				// LAMESPEC the Type production (23.2.12) doesn't include CustomMod* for genericinst, but C++ uses it, the verifier allows it and ildasm also supports it
				CustomModifiers mods = ReadCustomModifiers(module, br, context);
				if (mods.required != null || mods.optional != null)
				{
					if (reqmod == null)
					{
						reqmod = new Type[genArgCount][];
						optmod = new Type[genArgCount][];
					}
					reqmod[i] = mods.required;
					optmod[i] = mods.optional;
				}
				args[i] = ReadType(module, br, context);
			}
			return GenericTypeInstance.Make(type, args, reqmod, optmod);
		}
开发者ID:ngraziano,项目名称:mono,代码行数:40,代码来源:Signature.cs

示例10: ImportType

        public TypeReference ImportType(TypeReference type, IGenericContext context)
        {
            if (Mixin.IsTypeSpecification(type))
                return ImportTypeSpecification(type, context);

            var reference = new TypeReference(
                type.Namespace,
                type.Name,
                module,
                ImportScope(type.Scope),
                type.IsValueType);

            MetadataSystem.TryProcessPrimitiveTypeReference(reference);

            if (type.IsNested)
                reference.DeclaringType = ImportType(type.DeclaringType, context);

            if (type.HasGenericParameters)
                ImportGenericParameters(reference, type);

            return reference;
        }
开发者ID:FreshBirdZhe,项目名称:LSharp,代码行数:22,代码来源:Import.cs

示例11: ImportType

		public TypeReference ImportType (Type type, IGenericContext context, ImportGenericKind import_kind)
		{
			if (IsTypeSpecification (type) || ImportOpenGenericType (type, import_kind))
				return ImportTypeSpecification (type, context);

			var reference = new TypeReference (
				string.Empty,
				type.Name,
				module,
				ImportScope (type.Assembly),
				type.IsValueType);

			reference.etype = ImportElementType (type);

			if (IsNestedType (type))
				reference.DeclaringType = ImportType (type.DeclaringType, context, import_kind);
			else
				reference.Namespace = type.Namespace;

			if (type.IsGenericType)
				ImportGenericParameters (reference, type.GetGenericArguments ());

			return reference;
		}
开发者ID:jeroldhaas,项目名称:ContinuousTests,代码行数:24,代码来源:Import.cs

示例12: ResolveType

        /// <summary>
        /// </summary>
        /// <param name="fullName">
        /// </param>
        /// <param name="genericContext">
        /// </param>
        /// <returns>
        /// </returns>
        /// <exception cref="KeyNotFoundException">
        /// </exception>
        public IType ResolveType(string fullName, IGenericContext genericContext)
        {
            var peModuleSymbol = this.moduleDef as PEModuleSymbol;

            var typeSymbol = peModuleSymbol.GetMetadataDecoder(genericContext).GetTypeSymbolForSerializedType(fullName);
            if (typeSymbol.TypeKind == TypeKind.Error)
            {
                // try to find it in CoreLib
                typeSymbol =
                    new MetadataDecoder(peModuleSymbol.ContainingAssembly.CorLibrary.Modules[0] as PEModuleSymbol).GetTypeSymbolForSerializedType(fullName);
            }

            if (typeSymbol != null && typeSymbol.TypeKind != TypeKind.Error)
            {
                if (genericContext == null)
                {
                    return typeSymbol.OriginalDefinition.ToAdapter();
                }

                return typeSymbol.ToAdapter();
            }

            throw new KeyNotFoundException();
        }
开发者ID:afrog33k,项目名称:csnative,代码行数:34,代码来源:MetadataModuleAdapter.cs

示例13: ResolveToken

        /// <summary>
        /// </summary>
        /// <param name="token">
        /// </param>
        /// <param name="genericContext">
        /// </param>
        /// <returns>
        /// </returns>
        /// <exception cref="KeyNotFoundException">
        /// </exception>
        public object ResolveToken(int token, IGenericContext genericContext)
        {
            var peModuleSymbol = this.moduleDef as PEModuleSymbol;

            var typeDefHandle = MetadataTokens.Handle(token);
            var symbolForIlToken = peModuleSymbol.GetMetadataDecoder(genericContext).GetSymbolForILToken(typeDefHandle);
            var typeSymbol = symbolForIlToken as TypeSymbol;
            if (typeSymbol != null && typeSymbol.TypeKind != TypeKind.Error)
            {
                return SubstituteTypeSymbolIfNeeded(typeSymbol, genericContext).ToAdapter();
            }

            var fieldSymbol = symbolForIlToken as FieldSymbol;
            if (fieldSymbol != null)
            {
                return new MetadataFieldAdapter(SubstituteFieldSymbolIfNeeded(fieldSymbol, genericContext));
            }

            var methodSymbol = symbolForIlToken as MethodSymbol;
            if (methodSymbol != null)
            {
                return new MetadataMethodAdapter(SubstituteMethodSymbolIfNeeded(methodSymbol, genericContext));
            }

            throw new KeyNotFoundException();
        }
开发者ID:afrog33k,项目名称:csnative,代码行数:36,代码来源:MetadataModuleAdapter.cs

示例14: ConstructMethodSymbol

        private static MethodSymbol ConstructMethodSymbol(MethodSymbol methodSymbol, AbstractTypeParameterMap methodTypeSubstitution, IGenericContext genericContext)
        {
            var metadataGenericContext = genericContext as MetadataGenericContext;
            if (metadataGenericContext != null)
            {
                var customTypeSubstitution = metadataGenericContext.CustomTypeSubstitution;
                if (customTypeSubstitution != null)
                {
                    return new ConstructedMethodSymbol(methodSymbol, GetTypeArguments(methodSymbol.OriginalDefinition.TypeParameters, customTypeSubstitution, null));
                }
            }

            var metadataMethodAdapter = genericContext.MethodSpecialization as MetadataMethodAdapter;
            if (metadataMethodAdapter != null)
            {
                var methodSymbolContext = metadataMethodAdapter.MethodDef;
                var constructedFrom = methodSymbol.ConstructedFrom;
                return new ConstructedMethodSymbol(constructedFrom.ConstructedFrom, GetTypeArguments(constructedFrom.TypeParameters, methodSymbolContext, methodTypeSubstitution));
            }

            var metadataTypeAdapter = genericContext.TypeSpecialization as MetadataTypeAdapter;
            if (metadataTypeAdapter != null)
            {
                var namedTypeSymbolContext = metadataTypeAdapter.TypeDef as NamedTypeSymbol;
                var constructedFrom = methodSymbol.ConstructedFrom;
                return new ConstructedMethodSymbol(constructedFrom.ConstructedFrom, GetTypeArguments(constructedFrom.TypeParameters, namedTypeSymbolContext, methodTypeSubstitution));
            }

            return null;
        }
开发者ID:afrog33k,项目名称:csnative,代码行数:30,代码来源:MetadataModuleAdapter.cs

示例15: SubstituteMethodSymbolIfNeeded

        internal static MethodSymbol SubstituteMethodSymbolIfNeeded(MethodSymbol methodSymbol, IGenericContext genericContext)
        {
            if (MetadataGenericContext.IsNullOrEmptyOrNoSpecializations(genericContext))
            {
                return methodSymbol;
            }

            var method = new MetadataMethodAdapter(methodSymbol);
            if (!method.IsGenericMethodDefinition && !method.DeclaringType.IsGenericTypeDefinition)
            {
                return methodSymbol;
            }

            var resolvedMethodSymbol = methodSymbol;
            if (method.DeclaringType.IsGenericTypeDefinition)
            {
                var constructedContainingType = SubstituteTypeSymbolIfNeeded(methodSymbol.ContainingType, genericContext);
                var substitutedNamedTypeSymbol = constructedContainingType as SubstitutedNamedTypeSymbol;
                if (substitutedNamedTypeSymbol != null)
                {
                    resolvedMethodSymbol = new SubstitutedMethodSymbol(
                        substitutedNamedTypeSymbol,
                        methodSymbol.ConstructedFrom.OriginalDefinition);
                }
                else
                {
                    var typeDef = (method.DeclaringType as MetadataTypeAdapter).TypeDef;
                    constructedContainingType = SubstituteTypeSymbolIfNeeded(typeDef, genericContext);
                    resolvedMethodSymbol = (constructedContainingType as ArrayTypeSymbol).GetMembers(methodSymbol.Name)[0] as MethodSymbol;
                }
            }

            if (method.IsGenericMethodDefinition || method.IsGenericMethod)
            {
                return ConstructMethodSymbol(resolvedMethodSymbol, methodSymbol.TypeSubstitution, genericContext);
            }

            return resolvedMethodSymbol;
        }
开发者ID:afrog33k,项目名称:csnative,代码行数:39,代码来源:MetadataModuleAdapter.cs


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