I want to load my class dynamically by using the Unity DI container based on country code saved in variable.
Our win apps has a shipping functionality for which we use web service developed by 3rd party company like UPS, FedEx and Purolator.
Now how should I design my code with unity, so that I could load my shipping class based on country code stored in variable?
Suppose this is my sample or proposed class design:
public interface IShip
{
string Ship();
}
public class UPS : IShip
{
public string Ship()
{
}
}
public class FedEX : IShip
{
public string Ship()
{
}
}
public class Purolator : IShip
{
public string Ship()
{
}
}
How can I use unity to load class based on variable value.
What if GB
is stored in variable and I want to load UPS class and invoke ship function ?
Suppose FR
is stored in a variable and I want to load UPS class and invoke ship function ?
Suppose if US
is stored in variable and I want to load FedEx class and invoke ship function ?
Suppose CA
is stored in variable and I want to load Purolator class and invoke ship function ?