本文整理汇总了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);
}
}
}
示例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;
}
示例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++);
}
示例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;
}
}