PrefetchPath2 constructor.....

Posts   
 
    
simmotech
User
Posts: 1024
Joined: 01-Feb-2006
# Posted on: 02-Aug-2006 11:51:45   

So trivial its almost not worth mentioning but...

I dislike having to cast to int in the PrefetchPath2 constructor so I just tried adding an additional constructor:-

    public PrefetchPath2(Enum rootEntityType)
    {
        _rootEntityType = (int) Enum.ToObject(rootEntityType.GetType(), rootEntityType);
    }

This seems to work, so I can now type:-

PrefetchPath2 prefetchPath = new PrefetchPath2(EntityType.ShipEntity); simple_smile

Cheers Simon

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39619
Joined: 17-Aug-2003
# Posted on: 02-Aug-2006 12:45:22   

I didn't know that was possible simple_smile . I was always under the assumption, an int should be used because the enum type EntityType isn't known obviously inside the runtime lib.

Frans Bouma | Lead developer LLBLGen Pro
simmotech
User
Posts: 1024
Joined: 01-Feb-2006
# Posted on: 02-Aug-2006 13:41:00   

Otis wrote:

I didn't know that was possible simple_smile . I was always under the assumption, an int should be used because the enum type EntityType isn't known obviously inside the runtime lib.

Neither did I to be honest.

I was initially looking at some kind of TypeConverter to allow an implicit cast of EntityType to an int but I was looking around in Reflector and found ToObject and it worked first time.

There is also an Enum.GetUnderlyingType which could be used to check that the Enum is of the Int32 type.

Cheers Simon

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39619
Joined: 17-Aug-2003
# Posted on: 02-Aug-2006 13:44:54   

I've added it to the todo list. simple_smile

Frans Bouma | Lead developer LLBLGen Pro