Example #1
0
        //
        // Return all declared methods whose name matches "optionalNameFilter". If optionalNameFilter is null, return them all.
        //
        internal IEnumerable <RuntimeMethodInfo> GetDeclaredMethodsInternal(RuntimeNamedTypeInfo definingType, String optionalNameFilter)
        {
            if (definingType != null)
            {
                // We require the caller to pass a value that we could calculate ourselves because we're an iterator and we
                // don't want any MissingMetadataException that AnchoringType throws to be deferred.
                Debug.Assert(definingType.Equals(this.AnchoringTypeDefinitionForDeclaredMembers));

                MetadataReader reader = definingType.Reader;
                foreach (MethodHandle methodHandle in definingType.DeclaredMethodAndConstructorHandles)
                {
                    Method method = methodHandle.GetMethod(reader);

                    if ((optionalNameFilter != null) && !method.Name.StringEquals(optionalNameFilter, reader))
                    {
                        continue;
                    }

                    if (MetadataReaderExtensions.IsConstructor(ref method, reader))
                    {
                        continue;
                    }
                    yield return(RuntimeNamedMethodInfo.GetRuntimeNamedMethodInfo(methodHandle, definingType, this));
                }
            }

            foreach (RuntimeMethodInfo syntheticMethod in SyntheticMethods)
            {
                if (optionalNameFilter == null || optionalNameFilter == syntheticMethod.Name)
                {
                    yield return(syntheticMethod);
                }
            }
        }
Example #2
0
        internal IEnumerable <MethodInfo> CoreGetDeclaredMethods(NameFilter optionalNameFilter, RuntimeTypeInfo reflectedType)
        {
            RuntimeNamedTypeInfo definingType = AnchoringTypeDefinitionForDeclaredMembers;

            if (definingType != null)
            {
                MetadataReader reader = definingType.Reader;
                foreach (MethodHandle methodHandle in definingType.DeclaredMethodAndConstructorHandles)
                {
                    Method method = methodHandle.GetMethod(reader);

                    if (MetadataReaderExtensions.IsConstructor(ref method, reader))
                    {
                        continue;
                    }

                    if (optionalNameFilter == null || optionalNameFilter.Matches(method.Name, reader))
                    {
                        yield return(RuntimeNamedMethodInfo.GetRuntimeNamedMethodInfo(methodHandle, definingType, this, reflectedType));
                    }
                }
            }

            foreach (RuntimeMethodInfo syntheticMethod in SyntheticMethods)
            {
                if (optionalNameFilter == null || optionalNameFilter.Matches(syntheticMethod.Name))
                {
                    yield return(syntheticMethod);
                }
            }
        }
        internal sealed override IEnumerable <MethodInfo> CoreGetDeclaredMethods(NameFilter optionalNameFilter, RuntimeTypeInfo reflectedType, RuntimeTypeInfo contextTypeInfo)
        {
            MetadataReader reader = Reader;

            foreach (MethodHandle methodHandle in DeclaredMethodAndConstructorHandles)
            {
                Method method = methodHandle.GetMethod(reader);

                if (MetadataReaderExtensions.IsConstructor(ref method, reader))
                {
                    continue;
                }

                if (optionalNameFilter == null || optionalNameFilter.Matches(method.Name, reader))
                {
                    yield return(RuntimeNamedMethodInfo <NativeFormatMethodCommon> .GetRuntimeNamedMethodInfo(new NativeFormatMethodCommon(methodHandle, this, contextTypeInfo), reflectedType));
                }
            }
        }
Example #4
0
        internal IEnumerable <ConstructorInfo> CoreGetDeclaredConstructors(NameFilter optionalNameFilter)
        {
            //
            // - It may sound odd to get a non-null name filter for a constructor search, but Type.GetMember() is an api that does this.
            //
            // - All GetConstructor() apis act as if BindingFlags.DeclaredOnly were specified. So the ReflectedType will always be the declaring type and so is not passed to this method.
            //
            RuntimeNamedTypeInfo definingType = AnchoringTypeDefinitionForDeclaredMembers;

            if (definingType != null)
            {
                MetadataReader  reader      = definingType.Reader;
                RuntimeTypeInfo contextType = this;
                foreach (MethodHandle methodHandle in definingType.DeclaredMethodAndConstructorHandles)
                {
                    Method method = methodHandle.GetMethod(reader);

                    if (!MetadataReaderExtensions.IsConstructor(ref method, reader))
                    {
                        continue;
                    }

                    if (optionalNameFilter == null || optionalNameFilter.Matches(method.Name, reader))
                    {
                        yield return(RuntimePlainConstructorInfo.GetRuntimePlainConstructorInfo(methodHandle, definingType, contextType));
                    }
                }
            }

            foreach (RuntimeConstructorInfo syntheticConstructor in SyntheticConstructors)
            {
                if (optionalNameFilter == null || optionalNameFilter.Matches(syntheticConstructor.IsStatic ? ConstructorInfo.TypeConstructorName : ConstructorInfo.ConstructorName))
                {
                    yield return(syntheticConstructor);
                }
            }
        }
        internal sealed override IEnumerable <ConstructorInfo> CoreGetDeclaredConstructors(NameFilter optionalNameFilter, RuntimeTypeInfo contextTypeInfo)
        {
            //
            // - It may sound odd to get a non-null name filter for a constructor search, but Type.GetMember() is an api that does this.
            //
            // - All GetConstructor() apis act as if BindingFlags.DeclaredOnly were specified. So the ReflectedType will always be the declaring type and so is not passed to this method.
            //
            MetadataReader reader = Reader;

            foreach (MethodHandle methodHandle in DeclaredMethodAndConstructorHandles)
            {
                Method method = methodHandle.GetMethod(reader);

                if (!MetadataReaderExtensions.IsConstructor(ref method, reader))
                {
                    continue;
                }

                if (optionalNameFilter == null || optionalNameFilter.Matches(method.Name, reader))
                {
                    yield return(RuntimePlainConstructorInfo <NativeFormatMethodCommon> .GetRuntimePlainConstructorInfo(new NativeFormatMethodCommon(methodHandle, this, contextTypeInfo)));
                }
            }
        }