Are .Register and .RegisterType equivalent (for classes with parameterless constructors)?
autofac, c#, dependency-injection
Solution
Assuming your class only has one defined constructor, they should be functionally equivalent.
One internal difference would be that `RegisterType` will use reflection to determine that constructor to use while `Register` with a lambda has provided all the information needed.
Problem
When using AutoFac, you can use `.RegisterType` to associate a class with an interface, but you can also use `.Register` (which allows you to specify construtor arguments via a lambda). For classes that have a parameterless constructor, are these two methods equivalent? ``` var builder = new Autofac.ContainerBuilder(); builder.RegisterType<MyClass>().As<IMyInterface>(); builder.Register(x => new MyClass()).As<IMyInterface>(); ``` Is there any scenario where using `.RegisterType` is perferable?