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


C# ObservableCollection.OfType方法代码示例

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


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

示例1: HandleCollectionChanges

        private void HandleCollectionChanges(Client client, NotifyCollectionChangedEventArgs args, ObservableCollection<Interlocutor> actualCollection, ObservableCollection<object> nullCollection)
        {
            if (actualCollection.Count == 0)
            {
                nullCollection.Clear();
                nullCollection.Add(new NullInterlocutor(client));
                return;
            }
            var nullInterlocutor = nullCollection.OfType<NullInterlocutor>().FirstOrDefault();
            if (nullInterlocutor != null)
            {
                nullCollection.Remove(nullInterlocutor);
            }

            if (args.OldItems != null)
            {
                foreach (var oldItem in args.OldItems)
                {
                    nullCollection.Remove(oldItem);
                }
            }

            if (args.NewItems != null)
            {
                foreach (var newItem in args.NewItems)
                {
                    nullCollection.Insert(actualCollection.IndexOf((Interlocutor) newItem), newItem);
                }
            }
        }
开发者ID:zhongleiyang,项目名称:vstalk,代码行数:30,代码来源:InterlocutorCollectionConverter.cs

示例2: GetHeadItems

        private SnakePiecePresenter GetHeadItems(ObservableCollection<BasePresenterItem> itemsTo)
        {
            var snakePiecePresenterItems = itemsTo.OfType<SnakePiecePresenter>();
            if (!snakePiecePresenterItems.Any())
            {
                DebugHelper.WriteLog("error occured, not head items were found, so directino wasn't changed", "NewSnakesGameManager.cs");
                return null;
            }
            var head = snakePiecePresenterItems.FirstOrDefault((m) =>
            {
                return m.IsHead;
            });

            if (head == null)
            {
                return null;
            }
            return head;
        }
开发者ID:dorsev,项目名称:games,代码行数:19,代码来源:NewSnakesGameManager.cs

示例3: VisitBodyClauses

        /** <inheritdoc /> */
        protected override void VisitBodyClauses(ObservableCollection<IBodyClause> bodyClauses, QueryModel queryModel)
        {
            var i = 0;
            foreach (var join in bodyClauses.OfType<JoinClause>())
                VisitJoinClause(join, queryModel, i++);

            var hasGroups = ProcessGroupings(queryModel);

            i = 0;
            foreach (var where in bodyClauses.OfType<WhereClause>())
                VisitWhereClause(where, i++, hasGroups);

            i = 0;
            foreach (var orderBy in bodyClauses.OfType<OrderByClause>())
                VisitOrderByClause(orderBy, queryModel, i++);
        }
开发者ID:rlugojr,项目名称:ignite,代码行数:17,代码来源:CacheQueryModelVisitor.cs

示例4: Process

        public Process(TS_SimulatorModel simulatorModel, ProcessDescriptor processDescriptor, ObservableCollection<Resource> Resources) 
        {
            this.simulatorModel = simulatorModel;

            //ProcessStatus = ProcessStatusEnum.Undefined;
            ProcessName = processDescriptor.ProcessName;
            ArrivalTime = processDescriptor.ArrivalTime;

            // Burst-ök ellenőrése, amelyiknél nincs megfelelő erőforrás definiálva, törlésre kerül.
            BurstSequence = new ObservableCollection<BurstDescriptor>(processDescriptor.BurstSequence);
            List<BurstDescriptor> burstsWithIllegalResourceList = new List<BurstDescriptor>();
            foreach (BurstDescriptor burst in BurstSequence)
            {
                if (burst.BurstTime <= 0)
                {
                    burstsWithIllegalResourceList.Add(burst);
                    break;
                }

                if (burst.GetType() == typeof(IoBurstAsynchronousDescriptor)
                    || burst.GetType() == typeof(IoBurstSynchronousDescriptor))
                {
                    IoBurstDescriptor burstToCheckResource = (IoBurstDescriptor)burst;
                    
                    bool isResourceDefined = false;
                    foreach (Resource resource in Resources)
                    { 
                        if (resource.ResourceName.Equals(burstToCheckResource.ResourceName))
                        {
                            isResourceDefined = true;
                            break;
                        }
                    }
                    if (! isResourceDefined)
                    {
                        burstsWithIllegalResourceList.Add(burst);
                    }
                }
            }
            foreach (BurstDescriptor illegalBurst in burstsWithIllegalResourceList)
            {
                BurstSequence.Remove(illegalBurst);
            }

            // alapértékek beállítása az esetlegesen módosított BurstSequence alapján
            cpuTimeLeft = asynchronousTimeRunned = synchronousTimeRunned = 0;
            cpuTimeLeft = asynchronousTimeLeft = synchronousTimeLeft = 0;
            foreach (CpuBurstDescriptor burst in BurstSequence.OfType<CpuBurstDescriptor>())
            {
                cpuTimeLeft += burst.BurstTime;
            }
            foreach (IoBurstAsynchronousDescriptor burst in BurstSequence.OfType<IoBurstAsynchronousDescriptor>())
            {
                asynchronousTimeLeft += burst.BurstTime;
            }
            foreach (IoBurstSynchronousDescriptor burst in BurstSequence.OfType<IoBurstSynchronousDescriptor>())
            {
                synchronousTimeLeft += burst.BurstTime;
            }
            
        }
开发者ID:prokhyon,项目名称:OSAlgorithmSimulator,代码行数:61,代码来源:Process.cs


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