public List<IPlugin> LoadPlugins(string folderPath)
public static class ObjectFactory
private static Dictionary<Type, Func<object>> _cache = new Dictionary<Type, Func<object>>(); public static T Create<T>() activators dotnet 4.6.1
ConstructorInfo ctor = type.GetConstructor( BindingFlags.NonPublic | BindingFlags.Instance, null, Type.EmptyTypes, null); object instance = ctor.Invoke(null); Note: Activator itself doesn't directly call private constructors; you need the constructor's Invoke method. | Mechanism | Speed | Flexibility | Type safety | |-----------|-------|-------------|--------------| | new | Fastest | None | Compile-time | | Activator.CreateInstance | Slow | High (late binding) | Runtime cast required | | ConstructorInfo.Invoke | Slightly slower than Activator | Very high | Runtime | | Compiled Expression lambdas | Near new | High | Runtime | | FormatterServices.GetUninitializedObject | Fastest but dangerous | None (no constructor called) | None | _cache = new Dictionary<