I'd like init a unity container based on some type from an assembly ("OneOfMyAssemblies"). I'd like register all the types (Class) inherit a specific interface ("IInjectionMarker"). I get them, I create a variable with but I can't use them as a type. The problem is on the line :
unityContainer.RegisterType<interfaceName, typeName> (new InjectionConstructor("MyParameter"));
I get the error "Can't use variable as a type". How can I solve this ?
var types = new List<Type>();
types.AddRange(Assembly.Load("OneOfMyAssemblies")
    .GetTypeListImplementingTheInterface(typeof(IInjectionMarker)));
types.ForEach(h =>
{
    Type typeName= Type.GetType(h.Name, true);
    Type interfaceName = Type.GetType($"I{h.Name}", true);
    unityContainer.RegisterType<interfaceName, typeName> (
        new InjectionConstructor("MyParameter"));
});
 
    