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


C# MethodBuilder.GetToken方法代码示例

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


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

示例1: SetMethodSemantics

 private void SetMethodSemantics(MethodBuilder mdBuilder, MethodSemanticsAttributes semantics)
 {
     if (mdBuilder == null)
     {
         throw new ArgumentNullException("mdBuilder");
     }
     this.m_type.ThrowIfCreated();
     TypeBuilder.DefineMethodSemantics(this.m_module.GetNativeHandle(), this.m_evToken.Token, semantics, mdBuilder.GetToken().Token);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:9,代码来源:EventBuilder.cs

示例2: SetAddOnMethod

 	public void SetAddOnMethod(MethodBuilder mdBuilder)
 	{
         if (mdBuilder == null)
         {
 			throw new ArgumentNullException("mdBuilder");
         }
         
         m_type.ThrowIfCreated();
 		TypeBuilder.InternalDefineMethodSemantics(
 			m_module,
 			m_evToken.Token,
 			MethodSemanticsAttributes.AddOn, 
 			mdBuilder.GetToken().Token);
 	}
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:14,代码来源:eventbuilder.cs

示例3: SetMethodSemantics

        [System.Security.SecurityCritical]  // auto-generated
        private void SetMethodSemantics(MethodBuilder mdBuilder, MethodSemanticsAttributes semantics)
        {
            if (mdBuilder == null)
            {
                throw new ArgumentNullException(nameof(mdBuilder));
            }
            Contract.EndContractBlock();

            m_type.ThrowIfCreated();
            TypeBuilder.DefineMethodSemantics(
                m_module.GetNativeHandle(),
                m_evToken.Token,
                semantics,
                mdBuilder.GetToken().Token);
        }
开发者ID:Clockwork-Muse,项目名称:coreclr,代码行数:16,代码来源:EventBuilder.cs

示例4: 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

示例5: 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

示例6: ParameterBuilder

 [System.Security.SecurityCritical]  // auto-generated
 internal ParameterBuilder(
     MethodBuilder   methodBuilder, 
     int             sequence, 
     ParameterAttributes attributes, 
     String             strParamName)            // can be NULL string
 {
     m_iPosition = sequence;
     m_strParamName = strParamName;
     m_methodBuilder = methodBuilder;
     m_strParamName = strParamName;
     m_attributes = attributes;
     m_pdToken = new ParameterToken( TypeBuilder.SetParamInfo(
                 m_methodBuilder.GetModuleBuilder().GetNativeHandle(),
                 m_methodBuilder.GetToken().Token, 
                 sequence, 
                 attributes, 
                 strParamName));
 }
开发者ID:destinyclown,项目名称:coreclr,代码行数:19,代码来源:ParameterBuilder.cs

示例7: SetPInvokeAttributes

        // Reflection.Emit is missing API to set all PInvoke flags (only some can be set via available APIs).
        private void SetPInvokeAttributes(MethodBuilder method, string dllName, string importName, Cci.PInvokeAttributes attributes)
        {
            if (s_lazyTypeBuilder_SetPInvokeData == null)
            {
                s_lazyTypeBuilder_SetPInvokeData = typeof(TypeBuilder).GetMethod("SetPInvokeData", BindingFlags.NonPublic | BindingFlags.Static);

                if (s_lazyTypeBuilder_SetPInvokeData == null)
                {
                    throw new NotSupportedException("Ref.Emit limitation");
                }
            }

            s_lazyTypeBuilder_SetPInvokeData.Invoke(null, new[] { RuntimeModule, dllName, importName, method.GetToken().Token, attributes });
        }
开发者ID:furesoft,项目名称:roslyn,代码行数:15,代码来源:ReflectionEmitter.cs

示例8: SetMethodSemantics

        [System.Security.SecurityCritical]  // auto-generated
        private void SetMethodSemantics(MethodBuilder mdBuilder, MethodSemanticsAttributes semantics)
        {
            if (mdBuilder == null)
            {
                throw new ArgumentNullException(nameof(mdBuilder));
            }

            m_containingType.ThrowIfCreated();
            TypeBuilder.DefineMethodSemantics(
                m_moduleBuilder.GetNativeHandle(),
                m_prToken.Token,
                semantics,
                mdBuilder.GetToken().Token);
        }    
开发者ID:JonHanna,项目名称:coreclr,代码行数:15,代码来源:PropertyBuilder.cs

示例9: 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

示例10: AddOtherMethod

 	public void AddOtherMethod(MethodBuilder mdBuilder)
 	{
         if (mdBuilder == null)
         {
 			throw new ArgumentNullException("mdBuilder");
         }
         m_containingType.ThrowIfCreated();
 		TypeBuilder.InternalDefineMethodSemantics(
 			m_module,
 			m_prToken.Token,
 			MethodSemanticsAttributes.Other, 
 			mdBuilder.GetToken().Token);
 	}
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:13,代码来源:propertybuilder.cs


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