Share via


TimelineMarkerCollection 类

定义

表示可按索引单独访问的 TimelineMarker 对象的集合。 TimelineMarkerCollection 是一个有序列表,其中的顺序由集合中包含的每个 TimelineMarker的时间值决定。 有关这会如何影响收集 API 的详细信息,请参阅备注。

public ref class TimelineMarkerCollection sealed : IIterable<TimelineMarker ^>, IVector<TimelineMarker ^>
/// [Windows.Foundation.Metadata.Activatable(65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class TimelineMarkerCollection final : IIterable<TimelineMarker>, IVector<TimelineMarker>
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
class TimelineMarkerCollection final : IIterable<TimelineMarker>, IVector<TimelineMarker>
[Windows.Foundation.Metadata.Activatable(65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class TimelineMarkerCollection : IEnumerable<TimelineMarker>, IList<TimelineMarker>
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
public sealed class TimelineMarkerCollection : IEnumerable<TimelineMarker>, IList<TimelineMarker>
Public NotInheritable Class TimelineMarkerCollection
Implements IEnumerable(Of TimelineMarker), IList(Of TimelineMarker)
继承
Object Platform::Object IInspectable TimelineMarkerCollection
属性
实现

Windows 要求

设备系列
Windows 10 (在 10.0.10240.0 中引入)
API contract
Windows.Foundation.UniversalApiContract (在 v1.0 中引入)

注解

TimelineMarkerCollection 的集合 API

TimelineMarkerCollection 是一个有序列表,其中的顺序由集合中包含的每个 TimelineMarker的时间值决定。 TimelineMarkerCollection 的集合 API 在内部处理添加到集合中的每个新项,并将其添加到索引位置,该索引位置对应于集合中所有 TimelineMarker 项的所有 Time 值的更新顺序。

让 TimelineMarkerCollection 始终保持基于时间的顺序,以便枚举/循环访问集合会根据与正在播放的媒体资产的位置以及 MarkerReached 事件的触发顺序对应的顺序提供 TimelineMarker 值。 否则,如果集合不是 按时间排序的,则需要在使用之前按时间对集合进行排序。

  • 如果为 C++) 调用 Append (,则该项可能会添加到排序列表的开头、中间或末尾,具体取决于要添加的 TimelineMarker的时间值。
  • 如果为 C++ 调用 InsertAt () 则忽略 索引 参数。 TimelineMarker 项将添加到索引位置,该索引位置按 Time 值维护集合的顺序。
  • 如果使用 C++) 的 GetAt 方法 (来读取值,则根据内部逻辑添加项的方式,索引是正确的。 但由于你没有直接控制该逻辑,因此通常最好使用适用于 C++) 的 IndexOf (在排序列表中查找特定的 TimelineMarker
  • 如果使用 C++) (SetAt 方法设置值,则将删除之前位于该索引处的值,但集合将自行重新排序以保持 Time 值排序,因此添加的新 TimelineMarker 可能不在设置到的索引处。 这可能是一个坏主意,因为你无法确定删除哪个项目。 建议不要使用索引器来设置值。
  • RemoveAt 将删除指定的索引项,但当集合索引移动剩余 Time 值时,不会删除可能的重复项。 建议不要使用 RemoveAt

枚举 C# 或 Microsoft Visual Basic 中的集合

TimelineMarkerCollection 是可枚举的,因此可以使用特定于语言的语法(如 C# 中的 foreach )枚举集合中的项。 编译器为你执行类型强制转换,你无需显式转换为 IEnumerable<TimelineMarker> 。 如果需要显式强制转换(例如,如果要调用 GetEnumerator),请使用 TimelineMarker 约束强制转换为 IEnumerable<T>

构造函数

TimelineMarkerCollection()

初始化 TimelineMarkerCollection 类的新实例。

属性

Size

获取集合的大小 (计数) 。

方法

Append(TimelineMarker)

将新项添加到集合。

Clear()

从集合中移除所有项。

First()

返回集合中项的迭代器。

GetAt(UInt32)

返回位于指定索引处的项。

GetMany(UInt32, TimelineMarker[])

通过迭代器在一次传递中检索多个元素。

GetView()

获取集合中的不可变视图。

IndexOf(TimelineMarker, UInt32)

检索指定项的索引。

InsertAt(UInt32, TimelineMarker)

插入指定的项。

RemoveAt(UInt32)

删除指定索引处的项。

RemoveAtEnd()

删除集合中的最后一项。

ReplaceAll(TimelineMarker[])

首先清除集合,然后将提供的数组作为新项插入。

SetAt(UInt32, TimelineMarker)

将指定索引处的值设置为指定的 TimelineMarker 值。

适用于

另请参阅