Biorąc pod uwagę typ C #, pobierz jego klasy podstawowe i zaimplementowane interfejsy

Pracuję nad silnikiem gry w C #. Klasa, nad którą pracuję, jest nazywanaCEntityRegistry, a jego zadaniem jest śledzenie wielu przypadkówCEntity w grze. Moim celem jest możliwość wysyłania zapytań doCEntityRegistry z danym typem i uzyskaj listę każdego z nichCEntity tego typu.

Dlatego chciałbym zachować mapę:

private IDictionary<Type, HashSet<CEntity>> m_TypeToEntitySet;

I zaktualizuj rejestr w ten sposób:

private void m_UpdateEntityList()
        {
            foreach (CEntity theEntity in m_EntitiesToRemove.dequeueAll())
            {
                foreach (HashSet<CEntity> set in m_TypeToEntitySet.Values)
                {
                    if (set.Contains(theEntity))
                        set.Remove(theEntity);
                }
            }
            foreach (CEntity theEntity in m_EntitiesToAdd.dequeueAll())
            {
                Type entityType = theEntity.GetType();
                foreach (Type baseClass in entityType.GetAllBaseClassesAndInterfaces())
                  m_TypeToEntitySet[baseClass].Add(theEntity);

            }
        }

Mam problem, że nie ma żadnej funkcjiType.GetAllBaseClassesAndInterfaces- Jak chciałbym to napisać?

questionAnswers(4)

yourAnswerToTheQuestion