小编Xav*_*ier的帖子

ViewModel上的ObservableObject或INotifyPropertyChanged

我很好奇最好的事情是什么ViewModels.是实现界面INotifyPropertyChanged还是派生更好ObservableObject.

ObservableObjectclass实现INotifyPropertyChanged并执行一些无聊的代码RaisePropertyChanged.

INotifyPropertyChanged要求实施PropertyChanged事件.

从我的观点来看,使用它似乎更合乎逻辑ObservableObject,但在大多数教程中,它们都INotifyPropertyChanged在其上实现了接口ViewModel.

你认为这是为了简单还是有逻辑的原因?

c# wpf visual-studio-2010

13
推荐指数
1
解决办法
2万
查看次数

重构一个包含太多bool的方法

我在c#中有这个方法,我希望重构它.有太多的bool和线条.什么是最好的重构.创建一个新课程看起来有点矫枉过正,而简单地削减两个课程似乎很难.任何见解或指针将不胜感激.

重构的方法

    private DialogResult CheckForSireRestrictionInSubGroup(bool deletingGroup,string currentId)
    {
        DialogResult result = DialogResult.No;
        if (!searchAllSireList)
        {
            DataAccessDialog dlg = BeginWaitMessage();
            bool isClose = false;
            try
            {
                ArrayList deletedSire = new ArrayList();
                ISireGroupBE sireGroupBE = sireController.FindSireGroupSearch();

                if (sireGroupBE != null)
                {
                    //if the current group is in fact the seach group before saving
                    bool currentGroupIsSeachGroup = sireGroupBE.TheSireGroup.id == currentId; 

                    //if we have setting this group as search group
                    bool selectedAsSearchGroup = this.chkBoxSelectedSireGroup.Checked;

                    //if the group we currently are in is not longer …
Run Code Online (Sandbox Code Playgroud)

c# methods refactoring

6
推荐指数
1
解决办法
435
查看次数

标签 统计

c# ×2

methods ×1

refactoring ×1

visual-studio-2010 ×1

wpf ×1