我很好奇最好的事情是什么ViewModels
.是实现界面INotifyPropertyChanged
还是派生更好ObservableObject
.
ObservableObject
class实现INotifyPropertyChanged
并执行一些无聊的代码RaisePropertyChanged
.
INotifyPropertyChanged
要求实施PropertyChanged
事件.
从我的观点来看,使用它似乎更合乎逻辑ObservableObject
,但在大多数教程中,它们都INotifyPropertyChanged
在其上实现了接口ViewModel
.
你认为这是为了简单还是有逻辑的原因?
我在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)