NDepend以查找是否在构造函数中检查了控件

时间:2017-11-15 11:03:21

标签: c# wpf catel ndepend

在我使用Catel框架开发的WPF项目中,我正在使用IoC模式注入服务和存储库。我希望使用NDpend来查找是否所有注入的接口都应用了以下检查。 请考虑以下构造函数

  public ManageInstrumentsViewModel(IMarkToMarketRepository repository, IViewModelFactory viewModelFactory,
        IPortfoliosService portfoliosService, IPkInstrumentsService pkInstrumentsService)
    {
        this.repository = repository;
        this.viewModelFactory = viewModelFactory;

        this.portfoliosService = portfoliosService;
        this.pkInstrumentsService = pkInstrumentsService;

        Model = new FilterDateRangePortfolioModel {NeedPortfolio = false};
        PortfolioModel = new PortfolioModel();

        LoadMtmInstrumentsCommand = new TaskCommand(OnLoadMtmInstrumentsCommandExecute, (() => CanLoadMtmCurrenciesCommandExecute));
        ModifyValueCommand = new TaskCommand<MtmInstrument>(OnModifyValueCommandExecute, mtmCurrencyResult => IsFunctionReadWrite);
    }

这还没有得到我需要用NDepend验证的检查。

更正的应该是

 public ManageInstrumentsViewModel(IMarkToMarketRepository repository, IViewModelFactory viewModelFactory,
        IPortfoliosService portfoliosService, IPkInstrumentsService pkInstrumentsService)
    {

        Argument.IsNotNull(()=>repository);
        Argument.IsNotNull(()=> viewModelFactory);
        Argument.IsNotNull(()=> portfoliosService);
        Argument.IsNotNull(()=> pkInstrumentsService);

        this.repository = repository;
        this.viewModelFactory = viewModelFactory;

        this.portfoliosService = portfoliosService;
        this.pkInstrumentsService = pkInstrumentsService;

        Model = new FilterDateRangePortfolioModel {NeedPortfolio = false};
        PortfolioModel = new PortfolioModel();

        LoadMtmInstrumentsCommand = new TaskCommand(OnLoadMtmInstrumentsCommandExecute, (() => CanLoadMtmCurrenciesCommandExecute));
        ModifyValueCommand = new TaskCommand<MtmInstrument>(OnModifyValueCommandExecute, mtmCurrencyResult => IsFunctionReadWrite);
    }

可以找到Argument.IsNotNull here

0 个答案:

没有答案