Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private readonly IService _Service;
- public LoginViewModel(IService Service=null) //Also i want to make this innjection optional so i set it to NULL
- {
- _Service = Service;
- }
- private void MethodWhereIWantToUseService()
- {
- //_service is coming NULL because configuration or mapping of injection calls after this
- _Service.MYMethod();
- }
- public class ServicesModule : IModule
- {
- public void Initialize()
- {
- var container = ServiceLocator.Current.GetInstance<IUnityContainer>();
- container.RegisterType<IService, Service>();
- }
- }
- public class Bootstrapper : UnityBootstrapper
- {
- protected override void ConfigureModuleCatalog()
- {
- base.ConfigureModuleCatalog();
- ModuleCatalog catalog = (ModuleCatalog)this.ModuleCatalog;
- catalog.AddModule(typeof(ServicesModule));
- }
- }
Add Comment
Please, Sign In to add comment