• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Cecil.GenericInstanceMethod类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: MakeGenericMethod

 public static GenericInstanceMethod MakeGenericMethod(this MethodReference method, params TypeReference[] genericArguments)
 {
     var result = new GenericInstanceMethod(method);
     foreach (var argument in genericArguments)
         result.GenericArguments.Add(argument);
     return result;
 }
开发者ID:csuffyy,项目名称:ReactiveUI.Fody,代码行数:7,代码来源:CecilExtensions.cs


示例2: createCallResult

 protected override CallResult createCallResult(MethodReference method, GenericInstanceMethod gim, Block block, int callInstrIndex)
 {
     int methodId;
     if (!methodTokenToId.TryGetValue(method.MetadataToken.ToInt32(), out methodId))
         return null;
     return new MyCallResult(block, callInstrIndex, methodId, gim);
 }
开发者ID:Joelone,项目名称:de4dot,代码行数:7,代码来源:StringInliner.cs


示例3: GetEquality

    MethodReference GetEquality(TypeReference typeDefinition)
    {

        if (typeDefinition.IsArray)
        {
            return null;
        }
        if (typeDefinition.IsGenericParameter)
        {
            return null;
        }
        if (typeDefinition.Namespace.StartsWith("System.Collections"))
        {
            return null;
        }
        if (typeDefinition.IsGenericInstance)
        {
            if (typeDefinition.FullName.StartsWith("System.Nullable"))
            {
                var genericInstanceMethod = new GenericInstanceMethod(NullableEqualsMethod);
                var typeWrappedByNullable = ((GenericInstanceType) typeDefinition).GenericArguments.First();
                genericInstanceMethod.GenericArguments.Add(typeWrappedByNullable);

                return typeWrappedByNullable.IsGenericParameter ? ModuleDefinition.Import(genericInstanceMethod, typeWrappedByNullable.DeclaringType) : ModuleDefinition.Import(genericInstanceMethod);
            }
        }
        var equality = GetStaticEquality(typeDefinition);
        if (equality != null)
        {
            return ModuleDefinition.Import(equality);
        }
        return null;
    }
开发者ID:dj-pgs,项目名称:PropertyChanged,代码行数:33,代码来源:TypeEqualityFinder.cs


示例4: MakeGenericMethod

 public static GenericInstanceMethod MakeGenericMethod(this MethodReference reference, params TypeReference[] arguments)
 {
     var result = new GenericInstanceMethod(reference);
     foreach (var t in arguments)
         result.GenericArguments.Add(t);
     return result;
 }
开发者ID:rondoo,项目名称:framework,代码行数:7,代码来源:MsBuildExtensions.cs


示例5: MakeGenericMethod

 public static MethodReference MakeGenericMethod(this MethodReference self, params TypeReference[] arguments)
 {
     var method = new GenericInstanceMethod(self);
     foreach(var argument in arguments)
         method.GenericArguments.Add(argument);
     return method;
 }
开发者ID:Powerino73,项目名称:paradox,代码行数:7,代码来源:CecilExtensions.cs


示例6: InjectField

    void InjectField(TypeDefinition type, FieldDefinition fieldDefinition)
    {

        var staticConstructor = type.GetStaticConstructor();
        staticConstructor.Body.SimplifyMacros();
        var genericInstanceMethod = new GenericInstanceMethod(forContextDefinition);
        if (type.IsCompilerGenerated() && type.IsNested)
        {
            genericInstanceMethod.GenericArguments.Add(type.DeclaringType.GetGeneric());
        }
        else
        {
            genericInstanceMethod.GenericArguments.Add(type.GetGeneric());
        }
        var instructions = staticConstructor.Body.Instructions;
        type.Fields.Add(fieldDefinition);

        var returns = instructions.Where(_ => _.OpCode == OpCodes.Ret)
                                  .ToList();

        var ilProcessor = staticConstructor.Body.GetILProcessor();
        foreach (var returnInstruction in returns)
        {
            var newReturn = Instruction.Create(OpCodes.Ret);
            ilProcessor.InsertAfter(returnInstruction, newReturn);
            ilProcessor.InsertBefore(newReturn, Instruction.Create(OpCodes.Call, genericInstanceMethod));
            ilProcessor.InsertBefore(newReturn, Instruction.Create(OpCodes.Stsfld, fieldDefinition.GetGeneric()));
            returnInstruction.OpCode = OpCodes.Nop;
        }
        staticConstructor.Body.OptimizeMacros();
    }
开发者ID:vlaci,项目名称:Anotar,代码行数:31,代码来源:TypeProcessor.cs


示例7: Instance

        //that one is for normal use - like calling class members, etc
        public static MethodReference Instance(this MethodDefinition self)
        {
            var declaringType = self.DeclaringType.Instance();

            var reference = new MethodReference(self.Name, self.ReturnType, declaringType);
            reference.HasThis = self.HasThis;
            reference.ExplicitThis = self.ExplicitThis;
            reference.CallingConvention = self.CallingConvention;

            foreach (var parameter in self.Parameters)
                reference.Parameters.Add(new ParameterDefinition(parameter.ParameterType));

            foreach (var generic_parameter in self.GenericParameters)
                reference.GenericParameters.Add(new GenericParameter(generic_parameter.Name, reference));

            if (self.HasGenericParameters && !self.IsGetter && !self.IsSetter)
            {
                reference = new GenericInstanceMethod(reference);
                foreach (var genericParam in self.GenericParameters)
                    if (self.DeclaringType.GenericParameters.SingleOrDefault(m => m.Name == genericParam.Name) == null)
                        ((GenericInstanceMethod)(reference)).GenericArguments.Add(genericParam);
            }

            return reference;
        }
开发者ID:vlad-zapp,项目名称:Mice,代码行数:26,代码来源:Program.cs


示例8: ExecuteWinRT

    public void ExecuteWinRT()
    {
        var assemblyResolver = ModuleDefinition.AssemblyResolver;
        var systemRuntime = assemblyResolver.Resolve("System.Runtime");
        var systemRuntimeTypes = systemRuntime.MainModule.Types;

        var objectDefinition = systemRuntimeTypes.First(x => x.Name == "Object");

        var constructorDefinition = objectDefinition.Methods.First(x => x.IsConstructor);
        ObjectConstructor = ModuleDefinition.ImportReference(constructorDefinition);
        var objectEqualsMethodDefinition = objectDefinition.Methods.First(x => x.Name == "Equals" && x.Parameters.Count == 2);
        ObjectEqualsMethod = ModuleDefinition.ImportReference(objectEqualsMethodDefinition);

        var nullableDefinition = systemRuntimeTypes.FirstOrDefault(x => x.Name == "Nullable");
        NullableEqualsMethod = ModuleDefinition.ImportReference(nullableDefinition).Resolve().Methods.First(x => x.Name == "Equals");

        EqualityComparerTypeReference = systemRuntimeTypes.FirstOrDefault(x => x.Name == "EqualityComparer`1");

        var actionDefinition = systemRuntimeTypes.First(x => x.Name == "Action");
        ActionTypeReference = ModuleDefinition.ImportReference(actionDefinition);
        var actionConstructor = actionDefinition.Methods.First(x => x.IsConstructor);
        ActionConstructorReference = ModuleDefinition.ImportReference(actionConstructor);

        var systemObjectModel = assemblyResolver.Resolve("System.ObjectModel");
        var systemObjectModelTypes = systemObjectModel.MainModule.Types;

        var propChangedInterfaceDefinition = systemObjectModelTypes.First(x => x.Name == "INotifyPropertyChanged");
        PropChangedInterfaceReference = ModuleDefinition.ImportReference(propChangedInterfaceDefinition);

        var propChangedHandlerDefinition = systemObjectModelTypes.First(x => x.Name == "PropertyChangedEventHandler");
        PropChangedHandlerReference = ModuleDefinition.ImportReference(propChangedHandlerDefinition);
        ComponentModelPropertyChangedEventHandlerInvokeReference = ModuleDefinition.ImportReference(propChangedHandlerDefinition.Methods.First(x => x.Name == "Invoke"));
        var propChangedArgsDefinition = systemObjectModelTypes.First(x => x.Name == "PropertyChangedEventArgs");
        ComponentModelPropertyChangedEventConstructorReference = ModuleDefinition.ImportReference(propChangedArgsDefinition.Methods.First(x => x.IsConstructor));

        var delegateDefinition = systemRuntimeTypes.First(x => x.Name == "Delegate");
        var combineMethodDefinition = delegateDefinition.Methods
            .Single(x =>
                x.Name == "Combine" &&
                x.Parameters.Count == 2 &&
                x.Parameters.All(p => p.ParameterType == delegateDefinition));
        DelegateCombineMethodRef = ModuleDefinition.ImportReference(combineMethodDefinition);
        var removeMethodDefinition = delegateDefinition.Methods.First(x => x.Name == "Remove");
        DelegateRemoveMethodRef = ModuleDefinition.ImportReference(removeMethodDefinition);

        var systemThreading = assemblyResolver.Resolve("System.Threading");
        var interlockedDefinition = systemThreading.MainModule.Types.First(x => x.FullName == "System.Threading.Interlocked");
        var genericCompareExchangeMethodDefinition = interlockedDefinition
            .Methods.First(x =>
                x.IsStatic &&
                x.Name == "CompareExchange" &&
                x.GenericParameters.Count == 1 &&
                x.Parameters.Count == 3);
        var genericCompareExchangeMethod = ModuleDefinition.ImportReference(genericCompareExchangeMethodDefinition);

        InterlockedCompareExchangeForPropChangedHandler = new GenericInstanceMethod(genericCompareExchangeMethod);
        InterlockedCompareExchangeForPropChangedHandler.GenericArguments.Add(PropChangedHandlerReference);
    }
开发者ID:Fody,项目名称:PropertyChanged,代码行数:58,代码来源:MsCoreReferenceFinder.cs


示例9: Assets

        public Assets([NotNull] ModuleWeaver moduleWeaver)
        {
            if (moduleWeaver == null)
            {
                throw new ArgumentNullException("moduleWeaver");
            }

            _commands = new ConcurrentDictionary<string, CommandData>();
            _moduleDefinition = moduleWeaver.ModuleDefinition;
            _log = moduleWeaver;
            var settings = moduleWeaver.Settings;
            _allClasses = new Lazy<List<TypeDefinition>>(()=> settings.GetAllTypes(moduleWeaver).ToList());
            var types = new Types(moduleWeaver);
            _typeReferences = types;
            _typeDefinitions = types;
            
            var constructorDefinition = TypeDefinitions.Object.Methods.First(x => x.IsConstructor);
            _objectConstructorReference = ModuleDefinition.Import(constructorDefinition);
            var actionConstructor = TypeDefinitions.Action.Methods.First(x => x.IsConstructor);
            ActionConstructorReference = ModuleDefinition.Import(actionConstructor);
            var actionOfTConstructor = TypeDefinitions.ActionOfT.GetConstructors().First();
            _actionOfTConstructorReference = ModuleDefinition.Import(actionOfTConstructor);
            var actionOfTInvokerDefinition = TypeDefinitions.ActionOfT.Methods.First(x => x.Name == "Invoke");
            _actionOfTInvokeReference = ModuleDefinition.Import(actionOfTInvokerDefinition);            
            var funcConstructor = TypeDefinitions.FuncOfT.Resolve().Methods.First(m => m.IsConstructor && m.Parameters.Count == 2);
            _funcOfBoolConstructorReference = ModuleDefinition.Import(funcConstructor).MakeHostInstanceGeneric(TypeReferences.Boolean);
            var predicateOfTConstructor = TypeDefinitions.PredicateOfT.GetConstructors().First();
            _predicateOfTConstructorReference = ModuleDefinition.Import(predicateOfTConstructor);
            var predicateOfTInvokerDefinition = TypeDefinitions.PredicateOfT.Methods.First(x => x.Name == "Invoke");
            _predicateOfTInvokeReference = ModuleDefinition.Import(predicateOfTInvokerDefinition);
            var delegateCombineDefinition = TypeDefinitions.Delegate.Methods.First(x => x.Name == "Combine" && x.Parameters.Count == 2);
            _delegateCombineMethodReference = ModuleDefinition.Import(delegateCombineDefinition);
            var delegateRemoveDefinition = TypeDefinitions.Delegate.Methods.First(x => x.Name == "Remove" && x.Parameters.Count == 2);
            _delegateRemoveMethodReference = ModuleDefinition.Import(delegateRemoveDefinition);

            var interlockedCompareExchangeMethodDefinition = TypeDefinitions.Interlocked.Methods.First(
                x => x.Name == "CompareExchange"
                     && x.Parameters.Count == 3
                     && x.HasGenericParameters
            );
            _interlockedCompareExchangeOfT = ModuleDefinition.Import(interlockedCompareExchangeMethodDefinition);
            _interlockedCompareExchangeOfEventHandler = new GenericInstanceMethod(_interlockedCompareExchangeOfT);
            _interlockedCompareExchangeOfEventHandler.GenericArguments.Add(TypeReferences.EventHandler);
            //_interlockedCompareExchangeOfEventHandler = 
            if (TypeDefinitions.CommandManager != null)
            {
                var requeryEvent = TypeDefinitions.CommandManager.Resolve().Events.Single(evt => evt.Name == "RequerySuggested");
                _commandManagerAddRequerySuggestedMethodReference = ModuleDefinition.Import(requeryEvent.AddMethod);
                _commandManagerRemoveRequerySuggestedMethodReference = ModuleDefinition.Import(requeryEvent.RemoveMethod);
            }
            _commandImplementationConstructors = GetCommandImplementationConstructors();

            constructorDefinition =
                TypeDefinitions.ArgumentNullException.Methods.Single(
                    x => x.IsConstructor && x.HasParameters && x.Parameters.Count == 1);
            _argumentNullExceptionConstructorReference = ModuleDefinition.Import(constructorDefinition);
        }
开发者ID:brainoffline,项目名称:Commander.Fody,代码行数:57,代码来源:Assets.cs


示例10: CreateNewObjectMethod

        public bool CreateNewObjectMethod(AssemblyDefinition assembly, 
                                        MethodDefinition templateMethod, 
                                        IAssemblyTracker tracker, 
                                        INewTransformerInfoWrapper infoWrapper)
        {
            MethodDefinition factoryMethod = null;
              if ((factoryMethod = infoWrapper.GetFactoryMethod (templateMethod, assembly, tracker)) != null)
              {
            if (factoryMethod.GenericParameters.Count != 1 || factoryMethod.Parameters.Count != 1 || !factoryMethod.IsStatic)
              throw new ArgumentException ("Factory method to create object does not have correct signature [public static T Create<T> (ParamList)]");

            TypeReference returnType = templateMethod.DeclaringType;
            if (templateMethod.DeclaringType.HasGenericParameters)
            {
              returnType = new GenericInstanceType (templateMethod.DeclaringType);
              foreach (var a in templateMethod.DeclaringType.GenericParameters.ToArray ())
              {
            returnType.GenericParameters.Add (a);
            ((GenericInstanceType) returnType).GenericArguments.Add (a);
              }
            }

            var importedFactoryMethod = templateMethod.Module.Import (factoryMethod);
            var genericInstanceMethod = new GenericInstanceMethod (importedFactoryMethod);
            genericInstanceMethod.GenericArguments.Add (templateMethod.DeclaringType);

            var paramlistDef = factoryMethod.Parameters[0].ParameterType.Resolve ();
            var importedParamListCreateMethod = templateMethod.Module.Import (SearchParamListFactoryMethod (paramlistDef, templateMethod));

            if (importedParamListCreateMethod == null)
              throw new ArgumentException ("Factory method: no corresponding 'create' method could have been found. [argument count]");

            var newObjectMethod = new MethodDefinition (
                                                    infoWrapper.GetWrapperMethodName (templateMethod),
                                                    MethodAttributes.Public | MethodAttributes.Static, returnType
                                                    );
            var instructions = newObjectMethod.Body.Instructions;

            foreach (var param in templateMethod.Parameters)
            {
              newObjectMethod.Parameters.Add (param);
              instructions.Add (Instruction.Create (OpCodes.Ldarg, param));
            }

            instructions.Add(Instruction.Create (OpCodes.Call, importedParamListCreateMethod));
            instructions.Add(Instruction.Create (OpCodes.Call, genericInstanceMethod));

            instructions.Add (Instruction.Create (OpCodes.Ret));
            newObjectMethod.Body.OptimizeMacros ();

            newObjectMethod.IsHideBySig = true;
            templateMethod.DeclaringType.Methods.Add (newObjectMethod);
            return true;
              }
              return false;
        }
开发者ID:rubicon-oss,项目名称:AssemblyTransformer,代码行数:56,代码来源:ILCodeRewriter.cs


示例11: MakeGenericMethod

		public static MethodReference MakeGenericMethod (this MethodReference self, params TypeReference [] arguments)
		{
			if (self.GenericParameters.Count != arguments.Length)
				throw new ArgumentException ();

			var instance = new GenericInstanceMethod (self);
			foreach (var argument in arguments)
				instance.GenericArguments.Add (argument);

			return instance;
		}
开发者ID:0xb1dd1e,项目名称:cecil,代码行数:11,代码来源:Extensions.cs


示例12: GenericBindingContext

        private GenericBindingContext(GenericInstanceMethod method)
        {
            var definition = method.Resolve();

            for (int i = 0; i < definition.GenericParameters.Count; ++i)
            {
                var parameter = definition.GenericParameters[i];
                var binding = method.GenericArguments[i];
                _methodEntries.Add(new Entry(parameter.FullName, binding));
            }
        }
开发者ID:gmf520,项目名称:Smocks,代码行数:11,代码来源:GenericBindingContext.cs


示例13: CallEventInvoker

    public Instruction CallEventInvoker(PropertyDefinition propertyDefinition)
    {
        var method = typeNode.EventInvoker.MethodReference;

        if (method.HasGenericParameters)
        {
            var genericMethod = new GenericInstanceMethod(method);
            genericMethod.GenericArguments.Add(propertyDefinition.PropertyType);
            method = genericMethod;
        }

        return Instruction.Create(OpCodes.Callvirt, method);
    }
开发者ID:Fody,项目名称:PropertyChanged,代码行数:13,代码来源:PropertyWeaver.cs


示例14: ProcessGenericType

 internal static void ProcessGenericType(GenericInstanceType type, InflatedCollectionCollector generics, GenericInstanceMethod contextMethod, CollectionMode mode)
 {
     bool flag = generics.TypeDeclarations.Add(type);
     if (((mode != CollectionMode.Types) || flag) && ((mode != CollectionMode.MethodsAndTypes) || generics.TypeMethodDeclarations.Add(type)))
     {
         GenericContext genericContext = new GenericContext(type, contextMethod);
         Unity.Cecil.Visitor.Extensions.Accept(type.ElementType.Resolve(), new GenericContextAwareDeclarationOnlyVisitor(generics, genericContext, CollectionMode.Types));
         foreach (GenericInstanceType type2 in Enumerable.OfType<GenericInstanceType>(type.GenericArguments))
         {
             ProcessGenericType(Inflater.InflateType(genericContext, type2), generics, null, mode);
         }
     }
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:13,代码来源:GenericContextAwareDeclarationOnlyVisitor.cs


示例15: Convert

        public Either<MemberReference, PropertyReferenceContainer> Convert(IAstReference astReference, ModuleDefinition module, IReferenceProvider recursive)
        {
            var methodAst = astReference as AstGenericMethodWithTypeArguments;
            if (methodAst == null)
                return null;

            var method = recursive.Convert(methodAst.Actual, module, recursive).As<MethodReference>();
            var typeArguments = methodAst.GenericArgumentTypes.Select(a => recursive.Convert(a, module, recursive).As<TypeReference>());

            var result = new GenericInstanceMethod(method);
            typeArguments.ForEach(result.GenericArguments.Add);

            return result;
        }
开发者ID:ashmind,项目名称:light,代码行数:14,代码来源:GenericMethodWithArgumentsProvider.cs


示例16: GetCallableParamListCreateMethod

        public MethodReference GetCallableParamListCreateMethod(AssemblyDefinition assemblyDef, MethodReference ctor, IAssemblyTracker tracker)
        {
            var tempRef = GetOrCreateRemotionInterfacesReference (assemblyDef, ctor.DeclaringType.Module, tracker);
              var paramListCreateReference = GetOrCreateParamList (ctor.Parameters.Count, ctor.DeclaringType.Module, tempRef);

              if (ctor.Parameters.Count > 0)
              {
            paramListCreateReference = new GenericInstanceMethod (paramListCreateReference);

            foreach (var param in ctor.Parameters)
              ((GenericInstanceMethod) paramListCreateReference).GenericArguments.Add (param.ParameterType);
              }
              return paramListCreateReference;
        }
开发者ID:rubicon-oss,项目名称:AssemblyTransformer,代码行数:14,代码来源:MethodReferenceGeneratorWithImport.cs


示例17: MakeGeneric

        public static MethodReference MakeGeneric(this MethodReference method, params TypeReference[] args)
        {
            if (args.Length == 0)
                return method;

            if (method.GenericParameters.Count != args.Length)
                throw new ArgumentException("Invalid number of generic type arguments supplied");

            var genericTypeRef = new GenericInstanceMethod(method);
            foreach (var arg in args)
                genericTypeRef.GenericArguments.Add(arg);

            return genericTypeRef;
        }
开发者ID:fir3pho3nixx,项目名称:cryo-aop,代码行数:14,代码来源:MethodReferenceExtensions.cs


示例18: WeaveConstructorCalls

        public void WeaveConstructorCalls(IEnumerable<ConstructorCallWeave> weaves, FactoryMap factories)
        {
            MethodInfo getFactoryMethod = typeof(Factories).GetMethod("Create");
              foreach (ConstructorCallWeave weave in weaves)
              {
            Factory factory = factories.GetForObjectType(weave.Constructor.DeclaringType);
            _log.Log("Weaving {0} in {1}", factory.ObjectType, weave.ParentMethod);

            MethodReference getObjectMethodReference = weave.ParentAssembly.Import(getFactoryMethod);
            GenericInstanceMethod methodCall = new GenericInstanceMethod(getObjectMethodReference);
            methodCall.GenericArguments.Add(factory.ObjectType);

            CilWorker worker = weave.ParentMethod.Body.CilWorker;
            Instruction callGetFactory = worker.Create(OpCodes.Call, methodCall);
            worker.Replace(weave.NewInstruction, callGetFactory);
              }
        }
开发者ID:benlovell,项目名称:machine,代码行数:17,代码来源:FactoryCallWeaver.cs


示例19: GetCallableObjectFactoryCreateMethod

        public MethodReference GetCallableObjectFactoryCreateMethod(AssemblyDefinition assemblyDef, ModuleDefinition moduleDefinition, TypeReference instantiatedType, IAssemblyTracker tracker)
        {
            var tempRef = GetOrCreateRemotionInterfacesReference (assemblyDef, moduleDefinition, tracker);

              var objectFactoryReference = new TypeReference (_objectFactoryNamespace, _objectFactoryName, moduleDefinition, tempRef);
              var paramListReference = new TypeReference (_paramListNamespace, _paramListName, moduleDefinition, tempRef);

              var createReference = new MethodReference ("Create", moduleDefinition.TypeSystem.Void, objectFactoryReference);
              var createTypeParam = new GenericParameter ("T", createReference);

              createReference.GenericParameters.Add (createTypeParam);
              createReference.ReturnType = createTypeParam;
              createReference.Parameters.Add (new ParameterDefinition (moduleDefinition.TypeSystem.Boolean));
              createReference.Parameters.Add (new ParameterDefinition (paramListReference));
              createReference.Parameters.Add (new ParameterDefinition (new ArrayType (moduleDefinition.TypeSystem.Object)));

              var instanceMethod = new GenericInstanceMethod (createReference);
              instanceMethod.GenericArguments.Add (instantiatedType);

              return instanceMethod;
        }
开发者ID:rubicon-oss,项目名称:AssemblyTransformer,代码行数:21,代码来源:MethodReferenceGeneratorWithImport.cs


示例20: MakeGeneric

        public static MethodReference MakeGeneric(this MethodReference method, params TypeReference[] arguments)
        {
            if (method.GenericParameters.Count != arguments.Length)
            {
                throw new ArgumentException("Invalid number of generic type arguments supplied");
            }

            if (arguments.Length == 0)
            {
                return method;
            }

            GenericInstanceMethod genericTypeReference = new GenericInstanceMethod(method);

            foreach (TypeReference argument in arguments)
            {
                genericTypeReference.GenericArguments.Add(argument);
            }

            return genericTypeReference;
        }
开发者ID:pierresebastien,项目名称:CacheMethodResult,代码行数:21,代码来源:CecilHelper.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Cecil.GenericInstanceType类代码示例发布时间:2022-05-26
下一篇:
C# Cecil.FieldReference类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap