/// <summary> /// Create a new <see cref="IFactory"/> instance for a given type /// </summary> /// <param name="typeToCreate">The type instance to build</param> /// <param name="types">The types of the constructor arguments</param> /// <returns>Returns a new <see cref="IFactory"/> instance.</returns> public IFactory CreateFactory(Type typeToCreate, Type[] types) { string key = GenerateKey(typeToCreate, types); IFactory factory = _cachedfactories[key] as IFactory; if (factory == null) { lock (syncLock) { factory = _cachedfactories[key] as IFactory; if (factory == null) // double-check { factory = _factoryBuilder.CreateFactory(typeToCreate, types); _cachedfactories[key] = factory; } } } return(factory); }