/
PackagePartCollection.cs
66 lines (53 loc) · 1.95 KB
/
PackagePartCollection.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
namespace System.IO.Packaging
{
/// <summary>
/// This class is used to get an enumerator for the Parts in a container.
/// This is a part of the MMCF Packaging Layer APIs
/// </summary>
public class PackagePartCollection : IEnumerable<PackagePart>
{
#region Public Methods
/// <summary>
/// Returns an enumerator over all the Parts in the container
/// </summary>
/// <returns></returns>
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
/// <summary>
/// Returns an enumerator over all the Parts in the container
/// </summary>
/// <returns></returns>
IEnumerator<PackagePart> IEnumerable<PackagePart>.GetEnumerator()
{
return GetEnumerator();
}
/// <summary>
/// Returns an enumerator over all the Parts in the Container
/// </summary>
/// <returns></returns>
public IEnumerator<PackagePart> GetEnumerator()
{
//The Dictionary.Values property always returns a collection, even if empty. It never returns a null.
return _partList.Values.GetEnumerator();
}
#endregion Public Methods
#region Internal Constructor
internal PackagePartCollection(SortedList<PackUriHelper.ValidatedPartUri, PackagePart> partList)
{
Debug.Assert(partList != null, "partDictionary parameter cannot be null");
_partList = partList;
}
#endregion Internal Constructor
#region Private Members
private readonly SortedList<PackUriHelper.ValidatedPartUri, PackagePart> _partList;
#endregion Private Members
}
}