For instance I have this bit of code
public class ProductService{
private IProductDataSource _dataSource = DependencyManager.Get<IProductDataSource>();
public Product Get(int id){
return _dataSource.Select(id);
}
}
I have 2 different data source:
- XML file which contains the informations only in 1 language,
- a SQL data base which contains the informations in many languages.
So I created 2 implementation for IProductDataSource, for for each kind of datasource. But how do I send the required language to the SQL data source ?
- I add the parameter "language" to the method "IProductDataSource.Select" even if I won't use it in the case of the XML implementation.
- Inside the SQL implementation I get the language from a global state ?
- I add the language to the constructor of my SQL implementation, but then I won't use my DependencyManager and handle my self the dependency injection.
Maybe my first solution is not good.