我使用DAO对象,如Repository模式和服务,以及我有接口的每个服务。
public class PerformanceReportService : IPerformanceReportService
{
private IEmployeeService employeeService;
private IPersonalMetricsService personalMetricService;
private IDealStatusService dealStatusService;
private ISalesPlanService salesPlanService;
private IMetricServices metricServices;
public PerformanceReportService(
IMetricServices metricServices,
ISalesPlanService salesPlanService,
IDealStatusService dealStatusService,
IPersonalMetricsService personalMetricService,
IEmployeeService employeeService)
{
this.employeeService = new employeeService;
this.metricServices = new metricServices;
this.personalMetricService = new personalMetricService;
this.dealStatusService = new dealStatusService;
this.salesPlanService = new salesPlanService;
}
我想在显示页面
中调用tifs PerfomanceReportServicepublic partial class PerformanceReport : System.Web.UI.Page
{
protected void Page_Init(object sender, EventArgs e)
{
private IMetricServices metricServices;
private ISalesPlanService salesPlanService;
private IDealStatusService dealStatusService;
private IPersonalMetricsService personalMetricService;
private IEmployeeService employeeService;
protected void Page_Init(object sender, EventArgs e)
{
performanceService = new PerformanceReportService(metricServices,salesPlanService,dealStatusService,personalMetricService,employeeService);
}
}
}
我使用DAO对象,如Repository模式和服务,以及我有接口的每个服务。
public class PerformanceReportService : IPerformanceReportService
{
private IEmployeeService employeeService;
private IPersonalMetricsService personalMetricService;
private IDealStatusService dealStatusService;
private ISalesPlanService salesPlanService;
private IMetricServices metricServices;
public PerformanceReportService(
IMetricServices metricServices,
ISalesPlanService salesPlanService,
IDealStatusService dealStatusService,
IPersonalMetricsService personalMetricService,
IEmployeeService employeeService)
{
this.employeeService = new employeeService;
this.metricServices = new metricServices;
this.personalMetricService = new personalMetricService;
this.dealStatusService = new dealStatusService;
this.salesPlanService = new salesPlanService;
}
}
我想在显示页面
中调用tifs PerfomanceReportServicepublic partial class PerformanceReport : System.Web.UI.Page
{
protected void Page_Init(object sender, EventArgs e)
{
private IMetricServices metricServices;
private ISalesPlanService salesPlanService;
private IDealStatusService dealStatusService;
private IPersonalMetricsService personalMetricService;
private IEmployeeService employeeService;
protected void Page_Init(object sender, EventArgs e)
{
performanceService = new PerformanceReportService(metricServices,salesPlanService,dealStatusService,personalMetricService,employeeService);
}
}
}
在这种情况下,每次我的界面都 Null 。我的问题是我需要将 new 关键字绑定到Class的接口。我说我不喜欢t仍然使用IoC容器。