Ejemplo n.º 1
0
        public static List<ITypeDefinitionMember> FindRelatedExternalMembers(ITypeDefinitionMember member, CanIncludeCheck canInclude)
        {
            List<ITypeDefinitionMember> relatedMembers = new List<ITypeDefinitionMember>();
            Dictionary<uint, ITypeReference> participatingTypes = new Dictionary<uint, ITypeReference>();

            ITypeDefinition currentType = member.ContainingTypeDefinition;
            do
            {
                //
                // add the type
                //
                if (!canInclude(Util.CanonicalizeTypeReference(currentType)))
                {
                    participatingTypes.Add(currentType.InternedKey, currentType);
                }

                //
                // add any interfaces it implements that are part of the closure
                //

                foreach (ITypeReference iface in currentType.Interfaces)
                {
                    INamedTypeReference ifaceTemplate = Util.CanonicalizeTypeReference(iface);
                    // check the closure against the template type, but add 
                    // the specialized type to participatingTypes so that
                    // argument matching works
                    if (!canInclude(ifaceTemplate) &&
                        !participatingTypes.ContainsKey(iface.InternedKey))
                    {
                        // Should we add ifaceTemplate or iface?
                        participatingTypes.Add(iface.InternedKey, iface);
                    }
                }

                //
                // go up to the base type
                //
                currentType = TypeHelper.BaseClass(currentType);
            }
            while (currentType != null);

            foreach (ITypeReference type in participatingTypes.Values)
            {
                ITypeDefinitionMember relatedMember = FindRelatedMember(type, member);
                if (null != relatedMember)
                {
                    relatedMembers.Add(relatedMember);
                }
            }

            return relatedMembers;
        }
Ejemplo n.º 2
0
        public static List <ITypeDefinitionMember> FindRelatedExternalMembers(ITypeDefinitionMember member, CanIncludeCheck canInclude)
        {
            List <ITypeDefinitionMember>      relatedMembers     = new List <ITypeDefinitionMember>();
            Dictionary <uint, ITypeReference> participatingTypes = new Dictionary <uint, ITypeReference>();

            ITypeDefinition currentType = member.ContainingTypeDefinition;

            do
            {
                //
                // add the type
                //
                if (!canInclude(Util.CanonicalizeTypeReference(currentType)))
                {
                    participatingTypes.Add(currentType.InternedKey, currentType);
                }

                //
                // add any interfaces it implements that are part of the closure
                //

                foreach (ITypeReference iface in currentType.Interfaces)
                {
                    INamedTypeReference ifaceTemplate = Util.CanonicalizeTypeReference(iface);
                    // check the closure against the template type, but add
                    // the specialized type to participatingTypes so that
                    // argument matching works
                    if (!canInclude(ifaceTemplate) &&
                        !participatingTypes.ContainsKey(iface.InternedKey))
                    {
                        // Should we add ifaceTemplate or iface?
                        participatingTypes.Add(iface.InternedKey, iface);
                    }
                }

                //
                // go up to the base type
                //
                currentType = TypeHelper.BaseClass(currentType);
            }while (currentType != null);

            foreach (ITypeReference type in participatingTypes.Values)
            {
                ITypeDefinitionMember relatedMember = FindRelatedMember(type, member);
                if (null != relatedMember)
                {
                    relatedMembers.Add(relatedMember);
                }
            }

            return(relatedMembers);
        }