0
  1. Is it possible to registe the type (container.RegisterType()) in such a way that the type gets registered in container when the type is asked for using container.Resolve<> Method. I measn someting like Lazy Registration?

       container.RegisterType(typeof(IType), typeof(ConcreteType));
       var obj = _container.Resolve<IType>();
    
  2. Is it also possible by doing configuration in config file?

sudhirk
  • 423
  • 1
  • 5
  • 12

1 Answers1

1

Out of the box: No. Unity does quite some pre-processing (like looking up constructors, emitting IL code for fast object creation etc.) at registration time. It does not matter wether you use a config file or code for configuration.

What is your scenario for "lazy registration"? Isn't lazy instantiation enough? I never had a situation where the registration phase was that performance critical.

Sebastian Weber
  • 6,766
  • 2
  • 30
  • 49