如何摆脱对象引用而不将实例设置为对象?

时间:2019-05-26 07:10:46

标签: c# asp.net asp.net-mvc

简而言之,我在旧系统上工作,例如Classic c#和Webform,但是我们正在将软件升级到MVC。 我有一个插入服务来保存用户在我们的应用程序中执行的所有操作,并且我想在旧类上使用它,但是它无法正常工作,并且返回对象引用未设置对象的实例。 剂量与依赖关系有关?

  public interface IEventLogService
  {
     ServiceResult<bool> Insert(EventLogInsertDto model);
  }
.............................................................
  //this is my old class
  public class PaymentPlace : BizBaseGuid, IDataMigratable
  {
    private readonly IEventLogService eventLogService;
    public PaymentPlace(IEventLogService eventLogService) :this(Manager.GetProvider(SoftwareManager.Guid))
    {
      this.eventLogService = eventLogService;
    }
........
public new bool Update(Guid guid)
    {
      var isUpdated = base.Update(guid);
      if (isUpdated)
      {
        #region Set Related EventLog
        EventLogInsertDto insertModel = new EventLogInsertDto(EntityGuid, guid, EventFlag.Update, "Updated");
        eventLogService.Insert(insertModel);
        #endregion
      }
      return isUpdated;
    }
}

0 个答案:

没有答案