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


C# MethodBuilder.GetMethodSignature方法代码示例

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


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

示例1: ConstructorBuilder

        [System.Security.SecurityCritical]  // auto-generated
        internal ConstructorBuilder(String name, MethodAttributes attributes, CallingConventions callingConvention,
            Type[] parameterTypes, Type[][] requiredCustomModifiers, Type[][] optionalCustomModifiers, ModuleBuilder mod, TypeBuilder type)
        {
            int sigLength;
            byte[] sigBytes;
            MethodToken token;

            m_methodBuilder = new MethodBuilder(name, attributes, callingConvention, null, null, null, 
                parameterTypes, requiredCustomModifiers, optionalCustomModifiers, mod, type, false);

            type.m_listMethods.Add(m_methodBuilder);
            
            sigBytes = m_methodBuilder.GetMethodSignature().InternalGetSignature(out sigLength);
    
            token = m_methodBuilder.GetToken();
        }
开发者ID:Rayislandstyle,项目名称:dotnet-coreclr,代码行数:17,代码来源:ConstructorBuilder.cs

示例2: DefinePInvokeMethodHelperNoLock

        [System.Security.SecurityCritical]  // auto-generated
        private MethodBuilder DefinePInvokeMethodHelperNoLock(
            String name, String dllName, String importName, MethodAttributes attributes, CallingConventions callingConvention, 
            Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers,
            Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers,
            CallingConvention nativeCallConv, CharSet nativeCharSet)
        {
            if (name == null)
                throw new ArgumentNullException("name");

            if (name.Length == 0)
                throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "name");

            if (dllName == null)
                throw new ArgumentNullException("dllName");

            if (dllName.Length == 0)
                throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "dllName");

            if (importName == null)
                throw new ArgumentNullException("importName");

            if (importName.Length == 0)
                throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "importName");

            if ((attributes & MethodAttributes.Abstract) != 0)
                throw new ArgumentException(Environment.GetResourceString("Argument_BadPInvokeMethod"));
            Contract.EndContractBlock();

            if ((m_iAttr & TypeAttributes.ClassSemanticsMask) == TypeAttributes.Interface)
                throw new ArgumentException(Environment.GetResourceString("Argument_BadPInvokeOnInterface"));

            ThrowIfCreated();

            attributes = attributes | MethodAttributes.PinvokeImpl;
            MethodBuilder method = new MethodBuilder(name, attributes, callingConvention, 
                returnType, returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers,
                parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers,
                m_module, this, false);

            //The signature grabbing code has to be up here or the signature won't be finished
            //and our equals check won't work.
            int sigLength;
            byte[] sigBytes = method.GetMethodSignature().InternalGetSignature(out sigLength);

            if (m_listMethods.Contains(method))
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_MethodRedefined"));
            }
            m_listMethods.Add(method);

            MethodToken token = method.GetToken();
            
            int linkFlags = 0;
            switch(nativeCallConv)
            {
                case CallingConvention.Winapi:
                    linkFlags =(int)PInvokeMap.CallConvWinapi;
                    break;
                case CallingConvention.Cdecl:
                    linkFlags =(int)PInvokeMap.CallConvCdecl;
                    break;
                case CallingConvention.StdCall:
                    linkFlags =(int)PInvokeMap.CallConvStdcall;
                    break;
                case CallingConvention.ThisCall:
                    linkFlags =(int)PInvokeMap.CallConvThiscall;
                    break;
                case CallingConvention.FastCall:
                    linkFlags =(int)PInvokeMap.CallConvFastcall;
                    break;
            }
            switch(nativeCharSet)
            {
                case CharSet.None:
                    linkFlags |=(int)PInvokeMap.CharSetNotSpec;
                    break;
                case CharSet.Ansi:
                    linkFlags |=(int)PInvokeMap.CharSetAnsi;
                    break;
                case CharSet.Unicode:
                    linkFlags |=(int)PInvokeMap.CharSetUnicode;
                    break;
                case CharSet.Auto:
                    linkFlags |=(int)PInvokeMap.CharSetAuto;
                    break;
            }
            
            SetPInvokeData(m_module.GetNativeHandle(),
                dllName,
                importName,
                token.Token,
                linkFlags);
            method.SetToken(token);

            return method;
        }
开发者ID:uQr,项目名称:referencesource,代码行数:97,代码来源:typebuilder.cs

示例3: DefinePInvokeMethodHelperNoLock

        private MethodBuilder DefinePInvokeMethodHelperNoLock(string name, string dllName, string importName, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers, CallingConvention nativeCallConv, CharSet nativeCharSet)
        {
            int num;
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (name.Length == 0)
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "name");
            }
            if (dllName == null)
            {
                throw new ArgumentNullException("dllName");
            }
            if (dllName.Length == 0)
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "dllName");
            }
            if (importName == null)
            {
                throw new ArgumentNullException("importName");
            }
            if (importName.Length == 0)
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "importName");
            }
            if ((attributes & MethodAttributes.Abstract) != MethodAttributes.PrivateScope)
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_BadPInvokeMethod"));
            }
            if ((this.m_iAttr & TypeAttributes.ClassSemanticsMask) == TypeAttributes.ClassSemanticsMask)
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_BadPInvokeOnInterface"));
            }
            this.ThrowIfCreated();
            attributes |= MethodAttributes.PinvokeImpl;
            MethodBuilder item = new MethodBuilder(name, attributes, callingConvention, returnType, returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers, this.m_module, this, false);
            item.GetMethodSignature().InternalGetSignature(out num);
            if (this.m_listMethods.Contains(item))
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_MethodRedefined"));
            }
            this.m_listMethods.Add(item);
            MethodToken token = item.GetToken();
            int linkFlags = 0;
            switch (nativeCallConv)
            {
                case CallingConvention.Winapi:
                    linkFlags = 0x100;
                    break;

                case CallingConvention.Cdecl:
                    linkFlags = 0x200;
                    break;

                case CallingConvention.StdCall:
                    linkFlags = 0x300;
                    break;

                case CallingConvention.ThisCall:
                    linkFlags = 0x400;
                    break;

                case CallingConvention.FastCall:
                    linkFlags = 0x500;
                    break;
            }
            switch (nativeCharSet)
            {
                case CharSet.None:
                    break;

                case CharSet.Ansi:
                    linkFlags |= 2;
                    break;

                case CharSet.Unicode:
                    linkFlags |= 4;
                    break;

                case CharSet.Auto:
                    linkFlags |= 6;
                    break;
            }
            SetPInvokeData(this.m_module.GetNativeHandle(), dllName, importName, token.Token, linkFlags);
            item.SetToken(token);
            return item;
        }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:89,代码来源:TypeBuilder.cs

示例4: DefinePInvokeMethodHelper

        private MethodBuilder DefinePInvokeMethodHelper(
            String          name,                   // name of the function of the dll entry
            String          dllName,                // dll containing the PInvoke method
            String          importName,             // the import entry's name
            MethodAttributes attributes,
            CallingConventions callingConvention,
            Type            returnType,
            Type[]          parameterTypes,
            CallingConvention   nativeCallConv,     // The native calling convention.
            CharSet             nativeCharSet)      // Method's native character set.
        {
            try
            {
                Enter();

                ThrowIfCreated();

                if (name == null)
                    throw new ArgumentNullException("name");
                if (name.Length == 0)
                    throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "name");
                if (dllName == null)
                    throw new ArgumentNullException("dllName");
                if (dllName.Length == 0)
                    throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "dllName");
                if (importName == null)
                    throw new ArgumentNullException("importName");
                if (importName.Length == 0)
                    throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "importName");

                if ((m_iAttr & TypeAttributes.ClassSemanticsMask) == TypeAttributes.Interface)
                    throw new ArgumentException(Environment.GetResourceString("Argument_BadPInvokeOnInterface"));

                if ((attributes & MethodAttributes.Abstract) != 0)
                    throw new ArgumentException(Environment.GetResourceString("Argument_BadPInvokeMethod"));

                attributes = attributes | MethodAttributes.PinvokeImpl;
                MethodBuilder method = new MethodBuilder(name, attributes, callingConvention, returnType, parameterTypes, m_module, this, false);

                //The signature grabbing code has to be up here or the signature won't be finished
                //and our equals check won't work.
                int sigLength;
                byte[] sigBytes = method.GetMethodSignature().InternalGetSignature(out sigLength);

                if (m_listMethods.Contains(method)) {
                    throw new ArgumentException(Environment.GetResourceString("Argument_MethodRedefined"));
                }
                m_listMethods.Add(method);

                MethodToken token;
                
                token.m_method = InternalDefineMethod(m_tdType.Token,
                                                         name,
                                                         sigBytes,
                                                         sigLength,
                                                         attributes,
                                                         m_module);
                
                int linkFlags = 0;
                switch (nativeCallConv)
                {
                case CallingConvention.Winapi:
                    linkFlags = (int)PInvokeMap.CallConvWinapi;
                    break;
                case CallingConvention.Cdecl:
                    linkFlags = (int)PInvokeMap.CallConvCdecl;
                    break;
                case CallingConvention.StdCall:
                    linkFlags = (int)PInvokeMap.CallConvStdcall;
                    break;
                case CallingConvention.ThisCall:
                    linkFlags = (int)PInvokeMap.CallConvThiscall;
                    break;
                case CallingConvention.FastCall:
                    linkFlags = (int)PInvokeMap.CallConvFastcall;
                    break;
                }
                switch (nativeCharSet)
                {
                case CharSet.None:
                    linkFlags |= (int)PInvokeMap.CharSetNotSpec;
                    break;
                case CharSet.Ansi:
                    linkFlags |= (int)PInvokeMap.CharSetAnsi;
                    break;
                case CharSet.Unicode:
                    linkFlags |= (int)PInvokeMap.CharSetUnicode;
                    break;
                case CharSet.Auto:
                    linkFlags |= (int)PInvokeMap.CharSetAuto;
                    break;
                }
                
                InternalSetPInvokeData(m_module,
                                       dllName,
                                       importName,
                                       token.Token,
                                       0,
                                       linkFlags);
                method.SetToken(token);
//.........这里部分代码省略.........
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:typebuilder.cs

示例5: DefineMethod

        /// <include file='doc\TypeBuilder.uex' path='docs/doc[@for="TypeBuilder.DefineMethod1"]/*' />
        public MethodBuilder DefineMethod(
            String          name,
            MethodAttributes attributes,
            CallingConventions callingConvention,
            Type            returnType,
            Type[]          parameterTypes)
        {
            try
            {
                Enter();

                BCLDebug.Log("DYNIL","## DYNIL LOGGING: TypeBuilder.DefineMethod( " + name + " )");


                if (name == null)
                    throw new ArgumentNullException("name");
                if (name.Length == 0)
                    throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "name");

                ThrowIfCreated();

                if (!m_isHiddenGlobalType)
                {
                    if (((m_iAttr & TypeAttributes.ClassSemanticsMask) == TypeAttributes.Interface) &&
                        (attributes & MethodAttributes.Abstract)==0)
                        throw new ArgumentException(Environment.GetResourceString("Argument_BadAttributeOnInterfaceMethod"));               
                }

                // pass in Method attributes
                MethodBuilder method = new MethodBuilder(name, attributes, callingConvention, returnType, parameterTypes, m_module, this, false);

                //The signature grabbing code has to be up here or the signature won't be finished
                //and our equals check won't work.
                int sigLength;
                byte[] sigBytes = method.GetMethodSignature().InternalGetSignature(out sigLength);

                if (!m_isHiddenGlobalType)
                {
                    //If this method is declared to be a constructor,
                    //increment our constructor count.
                    if ((method.Attributes & MethodAttributes.SpecialName)!=0 &&
                        method.Name.Equals(ConstructorInfo.ConstructorName)) {
                        m_constructorCount++;
                    }
                }

                m_listMethods.Add(method);

                MethodToken token;
                
                token.m_method = InternalDefineMethod(m_tdType.Token,
                                                         name,
                                                         sigBytes,
                                                         sigLength,
                                                         method.Attributes,
                                                         m_module);

                method.SetToken(token);
                return method;
            }
            finally
            {
                Exit();
            }
        }
开发者ID:ArildF,项目名称:masters,代码行数:66,代码来源:typebuilder.cs

示例6: ConstructorBuilder

        /**********************************************
         * Constructs a ConstructorBuilder.  
        **********************************************/
        internal ConstructorBuilder(
            String              name, 
            MethodAttributes    attributes, 
            CallingConventions  callingConvention,
            Type[]              parameterTypes, 
            Module              mod, 
            TypeBuilder         type) 
        {
            int         sigLength;
            byte[]     sigBytes;
            MethodToken token;

            m_methodBuilder = new MethodBuilder(name, attributes, callingConvention, null, parameterTypes, mod, type, false);
            type.m_listMethods.Add(m_methodBuilder);
            
            sigBytes = m_methodBuilder.GetMethodSignature().InternalGetSignature(out sigLength);
    
            token.m_method = TypeBuilder.InternalDefineMethod(type.TypeToken.Token,
                                                     name, 
                                                     sigBytes, 
                                                     sigLength, 
                                                     attributes, 
                                                     mod);
            m_ReturnILGen = true;
            m_methodBuilder.SetToken(token);     
        }
开发者ID:ArildF,项目名称:masters,代码行数:29,代码来源:constructorbuilder.cs


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