1
我把我的變量爲一個基類是這樣的:訪問方法
public class BaseController : Controller
{
protected BaseViewModel vm { get; set; }
protected IAccountService _account;
protected IDataSourceService _dataSource;
protected IPackageService _package;
每個控制器目前執行以下操作:
private void InitializeServices(string ds, string ac = null, string pr = null, string pa = null, string co = null) {
_dataSource = new DataSourceService();
_account = new AccountService(ds);
_product = new ProductService(ds);
_package = new PackageService(ds);
但有什麼辦法我現在可以改變它,將InitializeService方法放入基類中,然後從派生類中調用它。如果可能的話,我將如何從派生類中調用該方法,並且一旦它位於基類內部時,該類的修飾符是什麼?這也會受到保護嗎?
謝謝安德魯。標記爲已接受。 – 2011-12-19 04:49:07