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


C# RuntimeMethodHandle.IsNullHandle方法代码示例

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


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

示例1: GetMethodFromHandle

        public static MethodBase GetMethodFromHandle(RuntimeMethodHandle handle)
        {
            if (handle.IsNullHandle())
                throw new ArgumentException(Environment.GetResourceString("Argument_InvalidHandle"));

#if !FEATURE_CORECLR
            if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
            {
                FrameworkEventSource.Log.BeginGetMethodFromHandle();
            }
#endif

            MethodBase m = RuntimeType.GetMethodBase(handle.GetMethodInfo());

            Type declaringType = m.DeclaringType;

#if !FEATURE_CORECLR
            if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage)  && declaringType != null)
            {
                FrameworkEventSource.Log.EndGetMethodFromHandle(declaringType.GetFullNameForEtw(), m.GetFullNameForEtw());
            }
#endif

            if (declaringType != null && declaringType.IsGenericType)
                throw new ArgumentException(String.Format(
                    CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_MethodDeclaringTypeGeneric"), 
                    m, declaringType.GetGenericTypeDefinition()));
 
            return m;
        }
开发者ID:peterdocter,项目名称:referencesource,代码行数:30,代码来源:methodbase.cs

示例2: GetMethodFromHandle

        public static MethodBase GetMethodFromHandle(RuntimeMethodHandle handle, RuntimeTypeHandle declaringType)
        {
            if (handle.IsNullHandle())
                throw new ArgumentException(Environment.GetResourceString("Argument_InvalidHandle"));

            return RuntimeType.GetMethodBase(declaringType.GetRuntimeType(), handle.GetMethodInfo());
        }
开发者ID:nietras,项目名称:coreclr,代码行数:7,代码来源:MethodBase.cs

示例3: GetMethodFromHandle

 public static MethodBase GetMethodFromHandle(RuntimeMethodHandle handle)
 {
     if (handle.IsNullHandle())
     {
         throw new ArgumentException(Environment.GetResourceString("Argument_InvalidHandle"));
     }
     MethodBase methodBase = RuntimeType.GetMethodBase(handle);
     if ((methodBase.DeclaringType != null) && methodBase.DeclaringType.IsGenericType)
     {
         throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_MethodDeclaringTypeGeneric"), new object[] { methodBase, methodBase.DeclaringType.GetGenericTypeDefinition() }));
     }
     return methodBase;
 }
开发者ID:randomize,项目名称:VimConfig,代码行数:13,代码来源:MethodBase.cs

示例4: GetMethodFromHandle

        public static MethodBase GetMethodFromHandle(RuntimeMethodHandle handle)
        {
            if (handle.IsNullHandle())
                throw new ArgumentException(Environment.GetResourceString("Argument_InvalidHandle"));

#if MONO
            MethodBase m = GetMethodFromHandleInternalType (handle.Value, IntPtr.Zero);
            if (m == null)
                throw new ArgumentException ("The handle is invalid.");
#else
            MethodBase m = RuntimeType.GetMethodBase(handle.GetMethodInfo());
#endif

            Type declaringType = m.DeclaringType;
            if (declaringType != null && declaringType.IsGenericType)
                throw new ArgumentException(String.Format(
                    CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_MethodDeclaringTypeGeneric"), 
                    m, declaringType.GetGenericTypeDefinition()));
 
            return m;
        }
开发者ID:stormleoxia,项目名称:referencesource,代码行数:21,代码来源:methodbase.cs

示例5: GetMethodInfo

        // this method is a big perf hit, so don't call unnecessarily
        internal static MethodInfo GetMethodInfo(RuntimeMethodHandle rmh)
        {
            if(rmh.IsNullHandle())
                return null;

#if _DEBUG
            try
            {
#endif
                // Assert here because reflection will check grants and if we fail the check,
                // there will be an infinite recursion that overflows the stack.
                PermissionSet.s_fullTrust.Assert();
                RuntimeTypeHandle rth = rmh.GetDeclaringType();
                return(System.RuntimeType.GetMethodBase(rth, rmh) as MethodInfo);
#if _DEBUG
            }
            catch(Exception)
            {
                return null;
            }
#endif
        }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:23,代码来源:securityruntime.cs

示例6: Emit

        public void Emit(OpCode opcode, RuntimeMethodHandle meth, RuntimeTypeHandle typeContext) { 
            if (meth.IsNullHandle()) 
                throw new ArgumentNullException("meth");
            if (typeContext.IsNullHandle()) 
                throw new ArgumentNullException("typeContext");

            // need to sort out the stack size story
            //int   stackchange = 0;
            int tempVal = m_scope.GetTokenFor(meth, typeContext);
            EnsureCapacity(7);
            InternalEmit(opcode);
            
            // need to sort out the stack size story
            /* 
            if (opcode.m_push == StackBehaviour.Varpush 
                && meth.ReturnType != typeof(void)) { stackchange++; } 
            if (opcode.m_pop  == StackBehaviour.Varpop) { 
               stackchange -= meth.GetParametersNoCopy().Length; }
            if (!meth.IsStatic && !(opcode.Equals(OpCodes.Newobj))) {stackchange--; }
            
            UpdateStackSize(opcode, stackchange);
            */
            // need to sort out the stack size story
            UpdateStackSize(opcode, 1);
            
            m_length=PutInteger4(tempVal, m_length, m_ILStream);
        }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:27,代码来源:dynamicilgenerator.cs

示例7: FilterCustomAttributeRecord

 internal static unsafe bool FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, ref Assembly lastAptcaOkAssembly, Module decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, bool mustBeInheritable, object[] attributes, IList derivedAttributes, out RuntimeType attributeType, out RuntimeMethodHandle ctor, out bool ctorHasParameters, out bool isVarArg)
 {
     ctor = new RuntimeMethodHandle();
     attributeType = null;
     ctorHasParameters = false;
     isVarArg = false;
     IntPtr ptr1 = (IntPtr) (((void*) caRecord.blob.Signature) + caRecord.blob.Length);
     attributeType = decoratedModule.ResolveType(scope.GetParentToken((int) caRecord.tkCtor), null, null) as RuntimeType;
     if (!attributeFilterType.IsAssignableFrom(attributeType))
     {
         return false;
     }
     if (!AttributeUsageCheck(attributeType, mustBeInheritable, attributes, derivedAttributes))
     {
         return false;
     }
     if ((attributeType.Assembly != lastAptcaOkAssembly) && !attributeType.Assembly.AptcaCheck(decoratedModule.Assembly))
     {
         return false;
     }
     lastAptcaOkAssembly = decoratedModule.Assembly;
     ConstArray methodSignature = scope.GetMethodSignature(caRecord.tkCtor);
     isVarArg = (methodSignature[0] & 5) != 0;
     ctorHasParameters = methodSignature[1] != 0;
     if (ctorHasParameters)
     {
         ctor = decoratedModule.ModuleHandle.ResolveMethodHandle((int) caRecord.tkCtor);
     }
     else
     {
         ctor = attributeType.GetTypeHandleInternal().GetDefaultConstructor();
         if (ctor.IsNullHandle() && !attributeType.IsValueType)
         {
             throw new MissingMethodException(".ctor");
         }
     }
     if (ctor.IsNullHandle())
     {
         if (!attributeType.IsVisible && !attributeType.TypeHandle.IsVisibleFromModule(decoratedModule.ModuleHandle))
         {
             return false;
         }
         return true;
     }
     if (ctor.IsVisibleFromModule(decoratedModule))
     {
         return true;
     }
     MetadataToken token = new MetadataToken();
     if (decoratedToken.IsParamDef)
     {
         token = new MetadataToken(scope.GetParentToken((int) decoratedToken));
         token = new MetadataToken(scope.GetParentToken((int) token));
     }
     else if ((decoratedToken.IsMethodDef || decoratedToken.IsProperty) || (decoratedToken.IsEvent || decoratedToken.IsFieldDef))
     {
         token = new MetadataToken(scope.GetParentToken((int) decoratedToken));
     }
     else if (decoratedToken.IsTypeDef)
     {
         token = decoratedToken;
     }
     return (token.IsTypeDef && ctor.IsVisibleFromType(decoratedModule.ModuleHandle.ResolveTypeHandle((int) token)));
 }
开发者ID:randomize,项目名称:VimConfig,代码行数:64,代码来源:CustomAttribute.cs

示例8: GetCustomAttributes

 internal static unsafe object[] GetCustomAttributes(Module decoratedModule, int decoratedMetadataToken, int pcaCount, RuntimeType attributeFilterType, bool mustBeInheritable, IList derivedAttributes)
 {
     if (decoratedModule.Assembly.ReflectionOnly)
     {
         throw new InvalidOperationException(Environment.GetResourceString("Arg_ReflectionOnlyCA"));
     }
     MetadataImport metadataImport = decoratedModule.MetadataImport;
     CustomAttributeRecord[] customAttributeRecords = CustomAttributeData.GetCustomAttributeRecords(decoratedModule, decoratedMetadataToken);
     Type elementType = (((attributeFilterType == null) || attributeFilterType.IsValueType) || attributeFilterType.ContainsGenericParameters) ? typeof(object) : attributeFilterType;
     if ((attributeFilterType == null) && (customAttributeRecords.Length == 0))
     {
         return (Array.CreateInstance(elementType, 0) as object[]);
     }
     object[] attributes = Array.CreateInstance(elementType, customAttributeRecords.Length) as object[];
     int length = 0;
     SecurityContextFrame frame = new SecurityContextFrame();
     frame.Push(decoratedModule.Assembly.InternalAssembly);
     Assembly lastAptcaOkAssembly = null;
     for (int i = 0; i < customAttributeRecords.Length; i++)
     {
         bool flag2;
         bool flag3;
         object obj2 = null;
         CustomAttributeRecord caRecord = customAttributeRecords[i];
         RuntimeMethodHandle ctor = new RuntimeMethodHandle();
         RuntimeType attributeType = null;
         int namedArgs = 0;
         IntPtr signature = caRecord.blob.Signature;
         IntPtr blobEnd = (IntPtr) (((void*) signature) + caRecord.blob.Length);
         if (FilterCustomAttributeRecord(caRecord, metadataImport, ref lastAptcaOkAssembly, decoratedModule, decoratedMetadataToken, attributeFilterType, mustBeInheritable, attributes, derivedAttributes, out attributeType, out ctor, out flag2, out flag3))
         {
             if (!ctor.IsNullHandle())
             {
                 ctor.CheckLinktimeDemands(decoratedModule, decoratedMetadataToken);
             }
             RuntimeConstructorInfo.CheckCanCreateInstance(attributeType, flag3);
             if (flag2)
             {
                 obj2 = CreateCaObject(decoratedModule, ctor, ref signature, blobEnd, out namedArgs);
             }
             else
             {
                 obj2 = attributeType.TypeHandle.CreateCaInstance(ctor);
                 if (Marshal.ReadInt16(signature) != 1)
                 {
                     throw new CustomAttributeFormatException();
                 }
                 signature = (IntPtr) (((void*) signature) + 2);
                 namedArgs = Marshal.ReadInt16(signature);
                 signature = (IntPtr) (((void*) signature) + 2);
             }
             for (int j = 0; j < namedArgs; j++)
             {
                 string str;
                 bool flag4;
                 Type type3;
                 object obj3;
                 IntPtr ptr1 = caRecord.blob.Signature;
                 GetPropertyOrFieldData(decoratedModule, ref signature, blobEnd, out str, out flag4, out type3, out obj3);
                 try
                 {
                     if (flag4)
                     {
                         if ((type3 == null) && (obj3 != null))
                         {
                             type3 = (obj3.GetType() == typeof(RuntimeType)) ? typeof(Type) : obj3.GetType();
                         }
                         RuntimePropertyInfo property = null;
                         if (type3 == null)
                         {
                             property = attributeType.GetProperty(str) as RuntimePropertyInfo;
                         }
                         else
                         {
                             property = attributeType.GetProperty(str, type3, Type.EmptyTypes) as RuntimePropertyInfo;
                         }
                         RuntimeMethodInfo setMethod = property.GetSetMethod(true) as RuntimeMethodInfo;
                         if (setMethod.IsPublic)
                         {
                             setMethod.MethodHandle.CheckLinktimeDemands(decoratedModule, decoratedMetadataToken);
                             setMethod.Invoke(obj2, BindingFlags.Default, null, new object[] { obj3 }, null, true);
                         }
                     }
                     else
                     {
                         (attributeType.GetField(str) as RtFieldInfo).InternalSetValue(obj2, obj3, BindingFlags.Default, Type.DefaultBinder, null, false);
                     }
                 }
                 catch (Exception exception)
                 {
                     throw new CustomAttributeFormatException(string.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString(flag4 ? "RFLCT.InvalidPropFail" : "RFLCT.InvalidFieldFail"), new object[] { str }), exception);
                 }
             }
             if (!signature.Equals(blobEnd))
             {
                 throw new CustomAttributeFormatException();
             }
             attributes[length++] = obj2;
         }
     }
//.........这里部分代码省略.........
开发者ID:randomize,项目名称:VimConfig,代码行数:101,代码来源:CustomAttribute.cs

示例9: Emit

 public void Emit(OpCode opcode, RuntimeMethodHandle meth, RuntimeTypeHandle typeContext)
 {
     if (meth.IsNullHandle())
     {
         throw new ArgumentNullException("meth");
     }
     if (typeContext.IsNullHandle())
     {
         throw new ArgumentNullException("typeContext");
     }
     int tokenFor = this.m_scope.GetTokenFor(meth, typeContext);
     base.EnsureCapacity(7);
     base.InternalEmit(opcode);
     base.UpdateStackSize(opcode, 1);
     base.PutInteger4(tokenFor);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:16,代码来源:DynamicILGenerator.cs

示例10: FilterCustomAttributeRecord

        internal unsafe static bool FilterCustomAttributeRecord(
            CustomAttributeRecord caRecord, MetadataImport scope, ref Assembly lastAptcaOkAssembly, 
            Module decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, bool mustBeInheritable,
            object[] attributes, IList derivedAttributes,
            out RuntimeType attributeType, out RuntimeMethodHandle ctor, out bool ctorHasParameters, out bool isVarArg)
        {
            ctor = new RuntimeMethodHandle();
            attributeType = null;
            ctorHasParameters = false;
            isVarArg = false;
            
            IntPtr blobStart = caRecord.blob.Signature;
            IntPtr blobEnd = (IntPtr)((byte*)blobStart + caRecord.blob.Length);

            // Resolve attribute type from ctor parent token found in decorated decoratedModule scope
            attributeType = decoratedModule.ResolveType(scope.GetParentToken(caRecord.tkCtor), null, null) as RuntimeType;

            // Test attribute type against user provided attribute type filter
            if (!(attributeFilterType.IsAssignableFrom(attributeType)))
                return false;

            if (!AttributeUsageCheck(attributeType, mustBeInheritable, attributes, derivedAttributes))
                return false;

            // APTCA checks
            if (attributeType.Assembly != lastAptcaOkAssembly && 
                !attributeType.Assembly.AptcaCheck(decoratedModule.Assembly))
                return false;

            // Cache last successful APTCA check (optimization)
            lastAptcaOkAssembly = decoratedModule.Assembly;

            // Resolve the attribute ctor
            ConstArray ctorSig = scope.GetMethodSignature(caRecord.tkCtor);
            isVarArg = (ctorSig[0] & 0x05) != 0;
            ctorHasParameters = ctorSig[1] != 0;

            if (ctorHasParameters)
            {
                // Resolve method ctor token found in decorated decoratedModule scope
                ctor = decoratedModule.ModuleHandle.ResolveMethodHandle(caRecord.tkCtor);
            }
            else
            {
                // Resolve method ctor token from decorated decoratedModule scope
                ctor = attributeType.GetTypeHandleInternal().GetDefaultConstructor();

                if (ctor.IsNullHandle() && !attributeType.IsValueType)
                    throw new MissingMethodException(".ctor");
            }

            // Visibility checks
            if (ctor.IsNullHandle())
            {
                if (!attributeType.IsVisible && !attributeType.TypeHandle.IsVisibleFromModule(decoratedModule.ModuleHandle))
                    return false;            
                
                return true;
            }
            
            if (ctor.IsVisibleFromModule(decoratedModule))
                return true;
            
            MetadataToken tkParent = new MetadataToken();
                
            if (decoratedToken.IsParamDef)
            {
                tkParent = new MetadataToken(scope.GetParentToken(decoratedToken));
                tkParent = new MetadataToken(scope.GetParentToken(tkParent));
            }               
            else if (decoratedToken.IsMethodDef || decoratedToken.IsProperty || decoratedToken.IsEvent || decoratedToken.IsFieldDef) 
            {
                tkParent = new MetadataToken(scope.GetParentToken(decoratedToken));
            }
            else if (decoratedToken.IsTypeDef)
            {
                tkParent = decoratedToken;
            }
            
            if (tkParent.IsTypeDef)
                return ctor.IsVisibleFromType(decoratedModule.ModuleHandle.ResolveTypeHandle(tkParent));
            
            return false;
        }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:84,代码来源:customattribute.cs

示例11: GetCustomAttributes

        internal unsafe static object[] GetCustomAttributes(
            Module decoratedModule, int decoratedMetadataToken, int pcaCount, 
            RuntimeType attributeFilterType, bool mustBeInheritable, IList derivedAttributes)
        {
            if (decoratedModule.Assembly.ReflectionOnly)
                throw new InvalidOperationException(Environment.GetResourceString("Arg_ReflectionOnlyCA"));

            MetadataImport scope = decoratedModule.MetadataImport;
            CustomAttributeRecord[] car = CustomAttributeData.GetCustomAttributeRecords(decoratedModule, decoratedMetadataToken);

            bool useObjectArray = (attributeFilterType == null || attributeFilterType.IsValueType || attributeFilterType.ContainsGenericParameters);
            Type arrayType = useObjectArray ? typeof(object) : attributeFilterType;

            if (attributeFilterType == null && car.Length == 0)
                return Array.CreateInstance(arrayType, 0) as object[];

            object[] attributes = Array.CreateInstance(arrayType, car.Length) as object[];
            int cAttributes = 0;

            // Custom attribute security checks are done with respect to the assembly *decorated* with the 
            // custom attribute as opposed to the *caller of GetCustomAttributes*.
            // Since this assembly might not be on the stack and the attribute ctor or property setters we're about to invoke may
            // make security demands, we push a frame on the stack as a proxy for the decorated assembly (this frame will be picked
            // up an interpreted by the security stackwalker).
            // Once we push the frame it will be automatically popped in the event of an exception, so no need to use CERs or the
            // like.
            SecurityContextFrame frame = new SecurityContextFrame();
            frame.Push(decoratedModule.Assembly);

            // Optimization for the case where attributes decorate entities in the same assembly in which case 
            // we can cache the successful APTCA check between the decorated and the declared assembly.
            Assembly lastAptcaOkAssembly = null;
            
            for (int i = 0; i < car.Length; i++)
            {
                object attribute = null;
                CustomAttributeRecord caRecord = car[i];

                RuntimeMethodHandle ctor = new RuntimeMethodHandle();
                RuntimeType attributeType = null;
                bool ctorHasParameters, isVarArg;
                int cNamedArgs = 0;
                
                IntPtr blobStart = caRecord.blob.Signature;
                IntPtr blobEnd = (IntPtr)((byte*)blobStart + caRecord.blob.Length);
                
                if (!FilterCustomAttributeRecord(caRecord, scope, ref lastAptcaOkAssembly, 
                                                 decoratedModule, decoratedMetadataToken, attributeFilterType, mustBeInheritable, 
                                                 attributes, derivedAttributes,
                                                 out attributeType, out ctor, out ctorHasParameters, out isVarArg))
                    continue;

                if (!ctor.IsNullHandle())
                {
                    // Linktime demand checks 
                    // decoratedMetadataToken needed as it may be "transparent" in which case we do a full stack walk
                    ctor.CheckLinktimeDemands(decoratedModule, decoratedMetadataToken);
                }
                else
                {
                }

                // Leverage RuntimeConstructorInfo standard .ctor verfication
                RuntimeConstructorInfo.CheckCanCreateInstance(attributeType, isVarArg); 

                // Create custom attribute object
                if (ctorHasParameters)
                {
                    attribute = CreateCaObject(decoratedModule, ctor, ref blobStart, blobEnd, out cNamedArgs); 
                }
                else
                {
                    attribute = attributeType.TypeHandle.CreateCaInstance(ctor);

                    if (Marshal.ReadInt16(blobStart) != 1)
                        throw new CustomAttributeFormatException();
                    blobStart = (IntPtr)((byte*)blobStart + 2); // skip 0x0001 prefix

                    cNamedArgs = Marshal.ReadInt16(blobStart);
                    blobStart = (IntPtr)((byte*)blobStart + 2); // skip namedArgs count
                }

                for (int j = 0; j < cNamedArgs; j++)
                {
                    #region // Initialize named properties and fields
                    string name;
                    bool isProperty;
                    Type type;
                    object value;
                    
                    IntPtr blobItr = caRecord.blob.Signature;

                    GetPropertyOrFieldData(decoratedModule, ref blobStart, blobEnd, out name, out isProperty, out type, out value);

                    try
                    {
                        if (isProperty)
                        {
                            #region // Initialize property
                            if (type == null && value != null)
//.........这里部分代码省略.........
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:101,代码来源:customattribute.cs

示例12: RuntimeMethodInfo

        internal RuntimeMethodInfo(
            RuntimeMethodHandle handle, RuntimeTypeHandle declaringTypeHandle, 
            RuntimeTypeCache reflectedTypeCache, MethodAttributes methodAttributes, BindingFlags bindingFlags)
        {
            ASSERT.PRECONDITION(!handle.IsNullHandle());            
            ASSERT.PRECONDITION(methodAttributes == handle.GetAttributes());            

            m_toString = null;
            m_bindingFlags = bindingFlags;
            m_handle = handle;
            m_reflectedTypeCache = reflectedTypeCache;
            m_parameters = null; // Created lazily when GetParameters() is called.
            m_methodAttributes = methodAttributes;
            m_declaringType = declaringTypeHandle.GetRuntimeType();
            ASSERT.POSTCONDITION(!m_handle.IsNullHandle());    
        }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:16,代码来源:xxxinfos.cs

示例13: CreateDelegate

		internal static Delegate CreateDelegate(Type type, object target, RuntimeMethodHandle method)
		{
			if (type == null)
			{
				throw new ArgumentNullException("type");
			}
			if (method.IsNullHandle())
			{
				throw new ArgumentNullException("method");
			}
			if (!(type is RuntimeType))
			{
				throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"), "type");
			}
			Type baseType = type.BaseType;
			if (baseType == null || baseType != typeof(MulticastDelegate))
			{
				throw new ArgumentException(Environment.GetResourceString("Arg_MustBeDelegate"), "type");
			}
			Delegate @delegate = Delegate.InternalAlloc(type.TypeHandle.GetRuntimeType());
			if ([email protected](target, method.GetMethodInfo(), RuntimeMethodHandle.GetDeclaringType(method.GetMethodInfo()), DelegateBindingFlags.RelaxedSignature))
			{
				throw new ArgumentException(Environment.GetResourceString("Arg_DlgtTargMeth"));
			}
			return @delegate;
		}
开发者ID:ChristianWulf,项目名称:CSharpKDMDiscoverer,代码行数:26,代码来源:Delegate.cs

示例14: CreateDelegateNoSecurityCheck

        [System.Security.SecurityCritical]  // auto-generated
        internal unsafe static Delegate CreateDelegateNoSecurityCheck(Type type, Object target, RuntimeMethodHandle method)
        {
            // Validate the parameters.
            if (type == null)
                throw new ArgumentNullException("type");
            Contract.EndContractBlock();

            if (method.IsNullHandle())
                throw new ArgumentNullException("method");

            RuntimeType rtType = type as RuntimeType;
            if (rtType == null)
                throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"), "type");
            
            if (!rtType.IsDelegate())
                throw new ArgumentException(Environment.GetResourceString("Arg_MustBeDelegate"),"type");
            
            // Initialize the method...
            Delegate d = InternalAlloc(rtType);
            // This is a new internal API added in Whidbey. Currently it's only
            // used by the dynamic method code to generate a wrapper delegate.
            // Allow flexible binding options since the target method is
            // unambiguously provided to us.
            // <

            if (!d.BindToMethodInfo(target,
                                    method.GetMethodInfo(),
                                    RuntimeMethodHandle.GetDeclaringType(method.GetMethodInfo()),
                                    DelegateBindingFlags.RelaxedSignature | DelegateBindingFlags.SkipSecurityChecks))
                throw new ArgumentException(Environment.GetResourceString("Arg_DlgtTargMeth"));
            return d;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:33,代码来源:Delegate.cs

示例15: CreateDelegate

        //
        // internal implementation details (FCALLS and utilities)
        //

        // V2 internal API.
        internal unsafe static Delegate CreateDelegate(Type type, Object target, RuntimeMethodHandle method)
        {
            // Validate the parameters.
            if (type == null)
                throw new ArgumentNullException("type");
            if (!(type is RuntimeType))
                throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"), "type");
            if (method.IsNullHandle())
                throw new ArgumentNullException("method");
            
            Type c = type.BaseType;
            if (c == null || c != typeof(MulticastDelegate))
                throw new ArgumentException(Environment.GetResourceString("Arg_MustBeDelegate"),"type");
            
            // Initialize the method...
            Delegate d = InternalAlloc(type.TypeHandle);
            // This is a new internal API added in Whidbey. Currently it's only
            // used by the dynamic method code to generate a wrapper delegate.
            // Allow flexible binding options since the target method is
            // unambiguously provided to us.
            if (!d.BindToMethodInfo(target, method, method.GetDeclaringType(), DelegateBindingFlags.RelaxedSignature))
                throw new ArgumentException(Environment.GetResourceString("Arg_DlgtTargMeth"));
            return d;
        }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:29,代码来源:delegate.cs


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