Sunday, 15 May 2011

reflection - Given a C# Type, Get its Base Classes and Implemented Interfaces -


I am working on a game engine in C #. The class I'm working on is called CENTityRegistry , and its job is to keep track of many examples of CENTITY in the game. > CENTITYRegistry to be able to query, and get the list of each CENTity of that type

what I want to do, therefore, create a map Have to keep:

  Private IDictionary & LT; Type, HashSet & LT; CENTITY & gt; & Gt; M_TypeToEntitySet;  

and registry thusly update:

  private zeros m_UpdateEntityList () {foreach (m_EntitiesToRemove.dequeueAll in CENTITY theEntity ()) {foreach (HashSet & LT; CENTITY> Set in M_TypeToEntitySet.Values) {If set (Set.Content (Entity)). Remove (ANTTI); }} Foreach (CNTTI Entity in M.Intead.dequali ()) {Type Entity Type = Entity. Gettype (); Foreach (entityType.GetAllBaseClassesAndInterface, type baseClass ()) m_TypeToEntitySet [baseClass] .Add (theEntity); }}  

The problem is that I have a function Type.GetAllBaseClassesAndInterface that's there - I would go about writing it how

Type A property BaseType and one method FindInterfaces. In fact, this is almost Type.GetAllBaseClassesAndInterface , but you have to make two calls instead of one.


No comments:

Post a Comment