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


C# ICollectionView.OfType方法代码示例

本文整理汇总了C#中ICollectionView.OfType方法的典型用法代码示例。如果您正苦于以下问题:C# ICollectionView.OfType方法的具体用法?C# ICollectionView.OfType怎么用?C# ICollectionView.OfType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICollectionView的用法示例。


在下文中一共展示了ICollectionView.OfType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DisplayAttentions

        public void DisplayAttentions(ICollectionView colview, string header)
        {
            if (colview == null)
            {
                return;
            }

            if (DPOS == null)
            {
                MessageBox.Show("Please refresh the database first before attentions check", "Warning!", MessageBoxButton.OK,
                    MessageBoxImage.Exclamation);
                return;
            }

            var pass = colview.OfType<PAUPassenger>();

            ObservableCollection<PAUPassenger> attentions = new ObservableCollection<PAUPassenger>();
            ObservableCollection<PAUPassenger> wnAttentions = new ObservableCollection<PAUPassenger>();
            ObservableCollection<PAUPassenger> dpos = new ObservableCollection<PAUPassenger>();

            bool found = false;
            
            foreach (PAUPassenger p in pass)
            {
                TimeSpan span = p.FlightDate.Value.Subtract(p.Date.Value);
                if (span <= TimeSpan.FromDays(BookingDateRange))
                {
                    attentions.Add(p);
                    found = true;
                }

                int count = (from dpo in DPOS
                             where
                             (p.FirstName.ToUpper().Contains(dpo.FirstName.ToUpper()) &&
                              p.LastName.ToUpper().Contains(dpo.LastName.ToUpper()))

                             //p.Passport.Equals(dpo.Passport)
                             select dpo).Distinct().Count();

                if (count > 0)
                {
                    dpos.Add(p);
                }
                
                foreach (NationalityAttention nat in Nationalities)
                {
                    if (p.Nationality != null)
                    {
                        if (p.Nationality.Equals(nat.Nationality, StringComparison.OrdinalIgnoreCase))
                        {
                            if (wnAttentions.Contains(p) == false)
                            {
                                wnAttentions.Add(p);
                                found = true;
                            }
                        }
                    }
                }
            }

            if (attentions.Count > 0)
            {
                DataGrid attentionGrid;
                SpawnNewDockWindow(string.Format("Attentions ({0})", header), out attentionGrid);
                if (attentionGrid != null)
                {
                    attentionGrid.ItemsSource = CollectionViewSource.GetDefaultView(attentions);
                }
            }

            if (wnAttentions.Count > 0)
            {
                DataGrid wnAttGrid;
                SpawnNewDockWindow(string.Format("WN Att ({0})", header), out wnAttGrid);
                if (wnAttGrid != null)
                {
                    wnAttGrid.ItemsSource = CollectionViewSource.GetDefaultView(wnAttentions);
                }
            }

            if (dpos.Count > 0)
            {
                DataGrid dpoGrid;
                SpawnNewDockWindow(string.Format("Name(s) On DPO ({0})", header), out dpoGrid);
                if (dpoGrid != null)
                {
                    dpoGrid.ItemsSource = CollectionViewSource.GetDefaultView(dpos);
                }
            }

            if (!found)
            {
                MessageBox.Show("No Attentions found", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
开发者ID:azanium,项目名称:PAU-WPF,代码行数:95,代码来源:MainController.cs


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