private TypeSignature GetDelegateTypeSig(ILCryptoMethod cryptoMethod)
        {
            var delegateType             = cryptoMethod.InvokeMethod.DelegateType;
            var delegateGenericArguments = cryptoMethod.DelegateGenericArguments;

            if (delegateGenericArguments != null && delegateGenericArguments.Length > 0)
            {
                return(new GenericTypeReference(delegateType.DeclaringType, delegateGenericArguments));
            }
            else
            {
                return(delegateType.DeclaringType);
            }
        }
        private MethodSignature GetInvokeMethodSig(ILCryptoMethod cryptoMethod, MethodReference calledMethodRef, BuildModule targetModule)
        {
            var invokeMethod = cryptoMethod.InvokeMethod;

            var invokeType = invokeMethod.OwnerType;

            var ownerTypeSig = GetInvokeTypeSig(invokeType, calledMethodRef.Owner, targetModule);

            var callSite = (CallSite)invokeMethod.CallSite.Relocate(_module, targetModule, true);

            var methodRef = new MethodReference(
                invokeType.InvokeMethodName,
                ownerTypeSig,
                callSite);

            if (invokeMethod.GenericParameterCount > 0)
            {
                var genericArguments       = new TypeSignature[invokeMethod.GenericParameterCount];
                var genericMethodArguments = cryptoMethod.InvokeGenericArguments;
                var genericTypeArguments   = ownerTypeSig.GenericArguments;

                for (int i = 0; i < genericMethodArguments.Length; i++)
                {
                    var genericMethodArgument = genericMethodArguments[i];

                    genericMethodArgument = (TypeSignature)genericMethodArgument.Relocate(_module, targetModule, true);

                    if (genericTypeArguments.Count > 0)
                    {
                        genericMethodArgument = (TypeSignature)genericMethodArgument.MapGenerics(genericTypeArguments, null);
                    }

                    genericArguments[i] = genericMethodArgument;
                }

                return(new GenericMethodReference(methodRef, genericArguments));
            }
            else
            {
                return(methodRef);
            }
        }
Beispiel #3
0
        public ILCryptoMethod CreateILCrypto()
        {
            ILCrypto = new ILCryptoMethod();

            return(_ilCrypto);
        }