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