EntityFactoryCache2.GetEntityFactory

Posts   
 
    
yowl
User
Posts: 271
Joined: 11-Feb-2008
# Posted on: 03-Mar-2009 18:06:23   

Version: 2.6.8.606

In the last method in this class :

        public static IEntityFactory2 GetEntityFactory(Type factoryType)
        {
            if(factoryType == null)
            {
                throw new ArgumentNullException("factory");
            }

            if(_factoryTypeLookup == null)
            {
                _factoryTypeLookup = new Dictionary<Type, IEntityFactory2>();
            }

            IEntityFactory2 result;
            if(!_factoryTypeLookup.TryGetValue(factoryType, out result))
            {
                result = (IEntityFactory2)Activator.CreateInstance(factoryType);
            }
            return result;
        }

Shouldn't it be adding the result to the Dictionary so that it doesn't have to create a factory each time as per the other methods in this class?

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 03-Mar-2009 21:35:49   

Quite possibly simple_smile

I'll get the developers to take a look.

Matt

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39859
Joined: 17-Aug-2003
# Posted on: 04-Mar-2009 10:11:06   

Good catch!

I'll add the code. I don't think that particular method is actually used inside the runtime (it's part of the fast serialization code)

Frans Bouma | Lead developer LLBLGen Pro