你们如何通过参数,让决心者制造物体?
我有一只紫外线物体,我想将其输入一个数据服务物体,我希望能够确保使用一个UoW物体制作特定序列的数据服务物体。
for example
using (var context = Resolver.GetService<IUoW>())
{
var dataService1 = Resolver.GetService<IDataService1>();
var dataService2 = Resolver.GetService<IDataService2>();
// do some stuff
context.Commit();
}
Option 1, pass IUoW into the Resolver.GetService call - there is no knowledge of the constructors for IDataServiceX implementations
Option 2, add a property to IDataServiceX for IUoW - not setting it would be easily done, how would a programmer know this property was required to be set