Ejemplo n.º 1
0
        public static IEnumerable <MethodDef> GetVisibleExtensionMethods(this MetadataTables tables)
        {
            MetadataRecord eaCtor = GetExtensionAttributeCtor(tables);

            if (!eaCtor.IsNull)
            {
                foreach (CustomAttributeDef ca in tables.CustomAttributes)
                {
                    if (ca.Constructor.Equals(eaCtor) && ca.Parent.IsMethodDef)
                    {
                        MethodDef mdef   = ca.Parent.MethodDef;
                        var       mattrs = mdef.Attributes;
                        if ((mattrs & MethodAttributes.MemberAccessMask) == MethodAttributes.Public && (mattrs & MethodAttributes.Static) != 0)
                        {
                            var declType = mdef.FindDeclaringType();
                            var tattrs   = declType.Attributes;
                            if (((tattrs & TypeAttributes.VisibilityMask) == TypeAttributes.Public ||
                                 (tattrs & TypeAttributes.VisibilityMask) == TypeAttributes.NestedPublic) &&
                                (tattrs & TypeAttributes.Abstract) != 0 &&
                                (tattrs & TypeAttributes.Sealed) != 0)
                            {
                                yield return(mdef);
                            }
                        }
                    }
                }
            }
        }