Simplest and slowest solution in case anybody needs it:
public static class MicroKernelExtensions {
public static T Create<T>(this IKernel kernel) {
return (T)kernel.Create(typeof(T));
}
public static object Create(this IKernel kernel, Type classType) {
var childKernel = new DefaultKernel { Parent = kernel };
childKernel.AddComponent(classType.Name, classType,
classType);
return childKernel.Resolve(classType);
}
}
This is ugly and *very* slow, 20 secs for 100000 Create vs 3 secs for
100000 Resolve for pre-registered component.
It is possible to add caching, and basic {Type => IKernel} caching
improves performance to be nearly equal to Resolve.
Since performance is not important for my case, and caching will
require good locking mechanism, I will use the above solution for now.