当前位置: 首页>>代码示例>>C#>>正文


C# IPredicate.Filter方法代码示例

本文整理汇总了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");
     }
 }
开发者ID:nikhilk,项目名称:silverlightfx,代码行数:8,代码来源:Task.cs

示例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");
        }
开发者ID:nikhilk,项目名称:silverlightfx,代码行数:65,代码来源:DataList.cs


注:本文中的IPredicate.Filter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。