[System.Security.SecurityCritical]  // auto-generated
        internal static bool IsDefined(RuntimeModule module, RuntimeType caType)
        {
            Contract.Requires(module != null);
            Contract.Requires(caType != null);

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

            if (PseudoCustomAttribute.IsDefined(module, caType))
                return true;

            return IsCustomAttributeDefined(module, module.MetadataToken, caType);
        }
        [System.Security.SecuritySafeCritical]  // auto-generated
        internal static bool IsDefined(RuntimeAssembly assembly, RuntimeType caType) 
        {
            Contract.Requires(assembly != null);
            Contract.Requires(caType != null);

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

            if (PseudoCustomAttribute.IsDefined(assembly, caType))
                return true;

            return IsCustomAttributeDefined(assembly.ManifestModule as RuntimeModule, RuntimeAssembly.GetToken(assembly.GetNativeHandle()), caType);
        }
        [System.Security.SecurityCritical]  // auto-generated
        internal static bool IsDefined(RuntimeType type, RuntimeType caType, bool inherit)
        {
            Contract.Requires(type != null);

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

            if (type.GetElementType() != null) 
                return false;

            if (PseudoCustomAttribute.IsDefined(type, caType))
                return true;

            if (IsCustomAttributeDefined(type.GetRuntimeModule(), type.MetadataToken, caType))
                return true;

            if (!inherit)
                return false;

            type = type.BaseType as RuntimeType;

            while (type != null)
            {
                if (IsCustomAttributeDefined(type.GetRuntimeModule(), type.MetadataToken, caType, 0, inherit))
                    return true;

                type = type.BaseType as RuntimeType;
            }

            return false;
        }
        [System.Security.SecuritySafeCritical]  // auto-generated
        internal static bool IsDefined(RuntimeMethodInfo method, RuntimeType caType, bool inherit)
        {
            Contract.Requires(method != null);
            Contract.Requires(caType != null);

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

            if (PseudoCustomAttribute.IsDefined(method, caType))
                return true;

            if (IsCustomAttributeDefined(method.GetRuntimeModule(), method.MetadataToken, caType))
                return true;

            if (!inherit)
                return false;

            method = method.GetParentDefinition();

            while (method != null)
            {
                if (IsCustomAttributeDefined(method.GetRuntimeModule(), method.MetadataToken, caType, 0, inherit))
                    return true;

                method = method.GetParentDefinition();
            }

            return false;
        }
Ejemplo n.º 5
0
        private Delegate CreateDelegateInternal(Type delegateType, Object firstArgument, DelegateBindingFlags bindingFlags, ref StackCrawlMark stackMark)
        {
            // Validate the parameters.
            if (delegateType == null)
            {
                throw new ArgumentNullException("delegateType");
            }
            Contract.EndContractBlock();

            RuntimeType rtType = delegateType as RuntimeType;

            if (rtType == null)
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"), "delegateType");
            }

            if (!rtType.IsDelegate())
            {
                throw new ArgumentException(Environment.GetResourceString("Arg_MustBeDelegate"), "delegateType");
            }

#if !FEATURE_CORECLR
            if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
            {
                FrameworkEventSource.Log.BeginMethodInfoCreateDelegate(GetRuntimeType() != null ? GetRuntimeType().GetFullNameForEtw() : "", GetFullNameForEtw(), rtType.GetFullNameForEtw());
            }
#endif

            Delegate d = Delegate.CreateDelegateInternal(rtType, this, firstArgument, bindingFlags, ref stackMark);
            if (d == null)
            {
                throw new ArgumentException(Environment.GetResourceString("Arg_DlgtTargMeth"));
            }

#if !FEATURE_CORECLR
            if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
            {
                FrameworkEventSource.Log.EndMethodInfoCreateDelegate(GetRuntimeType() != null ? GetRuntimeType().GetFullNameForEtw() : "", GetFullNameForEtw(), rtType.GetFullNameForEtw());
            }
#endif

            return(d);
        }