需要重构公共课

时间:2015-04-13 00:25:41

标签: c#

我有以下代码,我不知道如何最好地重构它。发生的事情是代码只处理第二个“公共MyShipService”,但我需要同时调用(或重构以使两者都工作)。有什么想法吗?

public class MyShipService : AnotherService, IShipService

public MyShipService(IStateService stateservice)
{
        _shipToService = new CallShipService();
        _stateService = stateService;
}
public MyShipService(ICountryService countryservice)
{
           _shipToService = new CallShipService();
        _countryService = countryService;
}
shippingAddresses.Each(sa => sa.State =_stateService.GetStateByAbbrev(sa.State.TwoLetterAbbr));
shippingAddresses.Each(sa => sa.Country = _countryService.GetCountryByAbbrev(sa.Country.TwoLetterAbbr));
return shippingAddresses;

1 个答案:

答案 0 :(得分:0)

对不起,伙计们......全脑屁。

有效的最终代码是......     public MyShipService(IStateService stateservice,ICountryservice countryservice)     {             _shipToService = new CallShipService();             _stateService = stateService;             _countryService = countryService;     }