I am using Unity block for Ioc implementation. I am using registerInstance and thats the way it will be. can't change it. The problem is if we do it what about the dependent objects? How to handle that. lets say
public ClientUser(IDataServiceManager dsm)
{
oDataServiceManager = dsm;
}
that works with registerType but as we have to creat the instance first
IClientUser clientUser = new ClientUser();
SnapFlowUnityContainer.Instance.RegisterInstance<IClientUser>(clientUser);
How can this work? our consultant said, use private getters to set the dependencies, let the class handle its dependent object? couldn't understand how to do that?
Update:
I need to know where i am wrong, How it will create the object of Dataservicemanger when i create clientUser
BootStrapper
IDataServiceManager dsm = new DataServiceManager();
IClientUser clientUser = new ClientUser();
SnapFlowUnityContainer.Instance.RegisterInstance<IDataServiceManager>(dsm);
SnapFlowUnityContainer.Instance.RegisterInstance<IClientUser>(clientUser);
Unit Test:
BootStrapper.Register();
IClientUser oIclientUser = SnapFlowUnityContainer.Instance.Resolve<IClientUser>();
ClientUser Class:
public class ClientUser : UserServiceBase, IClientUser
{
[Dependency]
private IDataServiceManager DataServiceMgr { get; set; }
}