private bool SearchFilter(object sender)
{
CommDGDataSource item = sender as CommDGDataSource;
if (FilterPropertyList.IsErrorFilter)
{
if (!item.Error)
return false;
}
if (FilterPropertyList.IsDestinationFilter)
{
if (!(item.Destination == FilterPropertyList.Destination))
return false;
}
if (FilterPropertyList.IsSourceFilter)
{
if (!(item.Source == FilterPropertyList.Source))
return false;
}
return true;
}
上面的代碼運行良好,但我想知道是否有更多的優雅的方式來編寫上述代碼。更優雅的處理這種邏輯的方式
我只會用'!'爲原子語句,在這種情況下'!='會救你的括號... – 2012-08-14 09:06:30
你也可以使用一個開關語句外,如果結構 – Terry 2012-08-14 09:08:20
的過濾器可以更比一次的事情?例如。它可以是'ErrorFilter'和'SourceFilter'嗎? – verdesmarald 2012-08-14 09:12:57