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


C# IGenericParameterProvider类代码示例

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


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

示例1: Fix

        private TypeReference Fix(TypeReference type, IGenericParameterProvider context)
        {
            if (type == null || type.IsDefinition)
                return type;

            if (type.IsGenericParameter)
            {
                var genPar = (GenericParameter)type;
                if (!fixedGenericParameters.Contains(genPar))
                {
                    fixedGenericParameters.Add(genPar);
                    FixReferences(genPar.Constraints, context);
                    FixReferences(genPar.CustomAttributes, context);
                }
                return type;
            }

            if (type is TypeSpecification)
                return Fix((TypeSpecification)type, context);
            
            var t2 = repack.GetMergedTypeFromTypeRef(type);
            if (t2 != null)
                return t2;
            
            if (type.IsNested)
                type.DeclaringType = Fix(type.DeclaringType, context);

            if (type.DeclaringType is TypeDefinition)
                return ((TypeDefinition)type.DeclaringType).NestedTypes.FirstOrDefault(x => x.FullName == type.FullName);
            
            return type;
        }
开发者ID:Fininvest,项目名称:il-repack,代码行数:32,代码来源:ReferenceFixator.cs

示例2: Push

		public void Push (IGenericParameterProvider provider)
		{
			if (stack == null)
				stack = new Collection<IGenericParameterProvider> (1) { provider };
			else
				stack.Add (provider);
		}
开发者ID:svermeulen,项目名称:cecil,代码行数:7,代码来源:Import.cs

示例3: ImportGenericParameters

        public static void ImportGenericParameters(IGenericParameterProvider imported, Type original)
        {
            var parameters = original.GetGenericTypeDefinition().GetGenericArguments();
            var imported_parameters = imported.GenericParameters;

            for (int i = 0; i < parameters.Length; i++)
                imported_parameters.Add(new GenericParameter(parameters[i].Name, imported));
        }
开发者ID:MarkusSintonen,项目名称:MNetInjector,代码行数:8,代码来源:CecilHelpers.cs

示例4: CheckProvider

		internal void CheckProvider (IGenericParameterProvider provider, int count)
		{
			if (!AllowCreation)
				return;

			for (int i = provider.GenericParameters.Count; i < count; i++)
				provider.GenericParameters.Add (new GenericParameter (provider));
		}
开发者ID:SAD1992,项目名称:justdecompile-plugins,代码行数:8,代码来源:GenericContext.cs

示例5: CopyGenericParameters

        public static void CopyGenericParameters(IGenericParameterProvider source, IGenericParameterProvider target, ReferenceResolver resolver)
        {
            if (!source.HasGenericParameters)
                return;

            foreach (var parameter in source.GenericParameters)
                target.InjectGenericParameter(parameter, resolver);
        }
开发者ID:Cadla,项目名称:OBFSCTR,代码行数:8,代码来源:MetadataBuilderHelper.cs

示例6: GetGenericParameter

 public TypeReference GetGenericParameter(GenericParameter genericParamter, IGenericParameterProvider[] paramProviders)
 {
     #if GENERIC
     IGenericParameterProvider context = GetContext(genericParamter, paramProviders);
     return context.GenericParameters[genericParamter.Position];
     #else
     return type;
     #endif
 }
开发者ID:Cadla,项目名称:OBFSCTR,代码行数:9,代码来源:ReferenceResolver.cs

示例7: GetGenericParameters

 public static Collection<GenericParameter> GetGenericParameters(
     IGenericParameterProvider self,
     ref Collection<GenericParameter> collection,
     ModuleDefinition module)
 {
     return Mixin.HasImage(module)
         ? module.Read(ref collection, self, (provider, reader) => reader.ReadGenericParameters(provider))
         : collection = new GenericParameterCollection(self);
 }
开发者ID:FreshBirdZhe,项目名称:LSharp,代码行数:9,代码来源:IGenericParameterProvider.cs

示例8: Process

	static void Process (IGenericParameterProvider provider)
	{
		if (!provider.HasGenericParameters)
			return;


		foreach (var parameter in provider.GenericParameters)
			Process (parameter);
	}
开发者ID:ALyman,项目名称:mono.linq.expressions,代码行数:9,代码来源:patch-constraints.cs

示例9: GenericParameter

        public GenericParameter(string name, IGenericParameterProvider owner)
            : base(string.Empty, name)
        {
            if (owner == null)
                throw new ArgumentNullException ();

            this.owner = owner;
            this.etype = owner.GenericParameterType == GenericParameterType.Type ? ElementType.Var : ElementType.MVar;
        }
开发者ID:n017,项目名称:Confuser,代码行数:9,代码来源:GenericParameter.cs

示例10: GenericContext

 public GenericContext(IGenericParameterProvider provider)
 {
     if (provider is TypeReference)
         m_type = provider as TypeReference;
     else if (provider is MethodReference) {
         MethodReference meth = provider as MethodReference;
         m_method = meth;
         m_type = meth.DeclaringType;
     }
 }
开发者ID:leftouterjoin,项目名称:loj-prj1,代码行数:10,代码来源:GenericContext.cs

示例11: ContainsGenericParameter

 public static bool ContainsGenericParameter(IGenericParameterProvider provider, TypeReference parameter)
 {
     foreach (var param in provider.GenericParameters)
     {
         if (param.MetadataToken == parameter.MetadataToken)
         {
             return true;
         }
     }
     return false;
 }
开发者ID:reicheltp,项目名称:website,代码行数:11,代码来源:CRefHelpers.cs

示例12: AssertGenericParametersAreIdentical

 private void AssertGenericParametersAreIdentical(IGenericParameterProvider expected, IGenericParameterProvider actual)
 {
     Assert.Equal(expected.HasGenericParameters, actual.HasGenericParameters);
     for (var i = 0; i < expected.GenericParameters.Count; i += 1)
     {
         var ap = expected.GenericParameters[i];
         var bp = actual.GenericParameters[i];
         Assert.Equal(ap.Name, bp.Name);
         Assert.Equal(ap.Position, bp.Position);
     }
 }
开发者ID:hach-que,项目名称:Dx,代码行数:11,代码来源:ProcessorUtilities.cs

示例13: Process

 public void Process(IGenericParameterProvider provider)
 {
     if (!provider.HasGenericParameters)
     {
         return;
     }
     foreach (var parameter in provider.GenericParameters
                                       .Where(x => x.HasCustomAttributes))
     {
         Process(parameter);
     }
 }
开发者ID:TylerBrinkley,项目名称:ExtraConstraints,代码行数:12,代码来源:GenericParameterProcessor.cs

示例14: GenericTypeFor

		static TypeReference GenericTypeFor (IGenericParameterProvider context)
		{
			var type = context as TypeReference;
			if (type != null)
				return type.GetElementType ();

			var method = context as MethodReference;
			if (method != null)
				return method.DeclaringType.GetElementType ();

			throw new InvalidOperationException ();
		}
开发者ID:svermeulen,项目名称:cecil,代码行数:12,代码来源:Import.cs

示例15: Fix

        internal MethodReference Fix(MethodReference method, IGenericParameterProvider context)
        {
            TypeReference declaringType = Fix(method.DeclaringType, context);
            if (method.IsGenericInstance)
            {
                return Fix((GenericInstanceMethod)method, context);
            }
            // if declaring type is in our new merged module, return the definition
            if (declaringType.IsDefinition && !method.IsDefinition)
            {
                MethodDefinition def = new ReflectionHelper(repack).FindMethodDefinitionInType((TypeDefinition)declaringType, method);
                if (def != null)
                    return def;
            }
            method.DeclaringType = declaringType;
            method.ReturnType = Fix(method.ReturnType, method);

            FixReferences(method.Parameters, method);
            FixReferences(method.GenericParameters, method);

            if (!method.IsDefinition &&
                !method.DeclaringType.IsGenericInstance &&
                !method.DeclaringType.IsArray &&
                (method.ReturnType.IsDefinition || method.Parameters.Any(x => x.ParameterType.IsDefinition)))
            {
                var culprit = method.ReturnType.IsDefinition
                                     ? method.ReturnType
                                     : method.Parameters.First(x => x.ParameterType.IsDefinition).ParameterType;
                // warn about invalid merge assembly set, as this method is not gonna work fine (peverify would warn as well)
                repack.WARN("Method reference is used with definition return type / parameter. Indicates a likely invalid set of assemblies, consider one of the following");
                repack.WARN(" - Remove the assembly defining " + culprit + " from the merge");
                repack.WARN(" - Add assembly defining " + method + " to the merge");

                // one case where it'll work correctly however (but doesn't seem common):
                // A references B
                // C references A
                // C is merged into B
            }
            return method;
        }
开发者ID:keremkusmezer,项目名称:il-repack,代码行数:40,代码来源:ReferenceFixator.cs


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