本文整理汇总了C#中IPredicate.Filter方法的典型用法代码示例。如果您正苦于以下问题:C# IPredicate.Filter方法的具体用法?C# IPredicate.Filter怎么用?C# IPredicate.Filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPredicate
的用法示例。
在下文中一共展示了IPredicate.Filter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Filter
public void Filter(IPredicate<Task> filter)
{
bool visible = filter.Filter(this);
if (visible != _visible) {
_visible = visible;
RaisePropertyChanged("IsVisible");
}
}
示例2: UpdateFilter
/// <summary>
/// Sets the predicate to use to filter the items contained in this DataList.
/// </summary>
/// <param name="predicate">The predicate to use; null if no filter is to be applied.</param>
public void UpdateFilter(IPredicate<object> predicate)
{
if ((_predicate == null) && (predicate == null)) {
return;
}
UpdateVersion();
if (_snapShot == null) {
RaisePropertyChanged("Count");
RaiseCollectionReset();
}
else {
object currentItem = null;
if (IsCurrencyEnabled) {
currentItem = CurrentItem;
}
// Potentially some items in the view are no longer in the snapshot and some new items
// now become part of the snapshot. First we'll remove any that no longer should be in
// the snapshot, and then we'll add whatever is.
if (predicate != null) {
for (int i = _snapShot.Count - 1; i >= 0; i--) {
object item = _snapShot[i];
if (predicate.Filter(item) == false) {
RemoveItem(item, i, /* raisePropertyChange */ false);
}
}
}
if (_predicate != null) {
foreach (object item in _sourceData) {
if ((_predicate.Filter(item) == false) &&
((predicate == null) || predicate.Filter(item))) {
AddItem(item, /* raisePropertyChange */ false);
}
}
}
if (currentItem != null) {
bool currentItemChanged = false;
int index = _snapShot.IndexOf(currentItem);
if (index == -1) {
index = 0;
}
CurrentIndex = index;
RaisePropertyChanged("CanMovePrevious");
RaisePropertyChanged("CanMoveNext");
if (currentItemChanged) {
RaisePropertyChanged("CurrentItem");
}
}
}
_predicate = predicate;
RaisePropertyChanged("Count");
}