|
2 | 2 | using System.Collections; |
3 | 3 | using System.Collections.Generic; |
4 | 4 |
|
5 | | -namespace Bunit |
| 5 | +namespace Bunit; |
| 6 | + |
| 7 | +/// <summary> |
| 8 | +/// Represents a collection of <see cref="IComponentFactory"/>. |
| 9 | +/// </summary> |
| 10 | +public sealed class ComponentFactoryCollection : IList<IComponentFactory> |
6 | 11 | { |
| 12 | + private readonly IList<IComponentFactory> factories = new List<IComponentFactory>(); |
| 13 | + |
7 | 14 | /// <summary> |
8 | | - /// Represents a collection of <see cref="IComponentFactory"/>. |
| 15 | + /// Gets or sets a <see cref="IComponentFactory"/> at the specified index. |
9 | 16 | /// </summary> |
10 | | - public sealed class ComponentFactoryCollection : IList<IComponentFactory> |
11 | | - { |
12 | | - private readonly IList<IComponentFactory> factories = new List<IComponentFactory>(); |
| 17 | + /// <param name="index">The zero-based index of the element to get or set.</param> |
| 18 | + /// <returns>The <see cref="IComponentFactory"/> at the specified index.</returns> |
| 19 | + public IComponentFactory this[int index] { get => factories[index]; set => factories[index] = value; } |
13 | 20 |
|
14 | | - /// <summary> |
15 | | - /// Gets or sets a <see cref="IComponentFactory"/> at the specified index. |
16 | | - /// </summary> |
17 | | - /// <param name="index">The zero-based index of the element to get or set.</param> |
18 | | - /// <returns>The <see cref="IComponentFactory"/> at the specified index.</returns> |
19 | | - public IComponentFactory this[int index] { get => factories[index]; set => factories[index] = value; } |
20 | | - |
21 | | - /// <summary> |
22 | | - /// Gets the number of <see cref="IComponentFactory"/> contained in the <see cref="ComponentFactoryCollection"/>. |
23 | | - /// </summary> |
24 | | - public int Count => factories.Count; |
| 21 | + /// <summary> |
| 22 | + /// Gets the number of <see cref="IComponentFactory"/> contained in the <see cref="ComponentFactoryCollection"/>. |
| 23 | + /// </summary> |
| 24 | + public int Count => factories.Count; |
25 | 25 |
|
26 | | - /// <summary> |
27 | | - /// Gets a value indicating whether the <see cref="ComponentFactoryCollection"/> is read-only. |
28 | | - /// </summary> |
29 | | - public bool IsReadOnly => factories.IsReadOnly; |
| 26 | + /// <summary> |
| 27 | + /// Gets a value indicating whether the <see cref="ComponentFactoryCollection"/> is read-only. |
| 28 | + /// </summary> |
| 29 | + public bool IsReadOnly => factories.IsReadOnly; |
30 | 30 |
|
31 | | - /// <summary> |
32 | | - /// Adds an <see cref="IComponentFactory"/> to the <see cref="ComponentFactoryCollection"/>. |
33 | | - /// </summary> |
34 | | - /// <param name="item">The <see cref="IComponentFactory"/> to add to the collection.</param> |
35 | | - public void Add(IComponentFactory item) => factories.Add(item); |
| 31 | + /// <summary> |
| 32 | + /// Adds an <see cref="IComponentFactory"/> to the <see cref="ComponentFactoryCollection"/>. |
| 33 | + /// </summary> |
| 34 | + /// <param name="item">The <see cref="IComponentFactory"/> to add to the collection.</param> |
| 35 | + public void Add(IComponentFactory item) => factories.Add(item); |
36 | 36 |
|
37 | | - /// <summary> |
38 | | - /// Removes all <see cref="IComponentFactory"/>s from the <see cref="ComponentFactoryCollection"/>. |
39 | | - /// </summary> |
40 | | - public void Clear() => factories.Clear(); |
| 37 | + /// <summary> |
| 38 | + /// Removes all <see cref="IComponentFactory"/>s from the <see cref="ComponentFactoryCollection"/>. |
| 39 | + /// </summary> |
| 40 | + public void Clear() => factories.Clear(); |
41 | 41 |
|
42 | | - /// <summary> |
43 | | - /// Determines whether the <see cref="ComponentFactoryCollection"/> contains a specific <see cref="IComponentFactory"/>. |
44 | | - /// </summary> |
45 | | - /// <param name="item">The object to locate in the <see cref="ComponentFactoryCollection"/>..</param> |
46 | | - /// <returns>true if item is found in the <see cref="ComponentFactoryCollection"/>; otherwise, false.</returns> |
47 | | - public bool Contains(IComponentFactory item) => factories.Contains(item); |
| 42 | + /// <summary> |
| 43 | + /// Determines whether the <see cref="ComponentFactoryCollection"/> contains a specific <see cref="IComponentFactory"/>. |
| 44 | + /// </summary> |
| 45 | + /// <param name="item">The object to locate in the <see cref="ComponentFactoryCollection"/>..</param> |
| 46 | + /// <returns>true if item is found in the <see cref="ComponentFactoryCollection"/>; otherwise, false.</returns> |
| 47 | + public bool Contains(IComponentFactory item) => factories.Contains(item); |
48 | 48 |
|
49 | | - /// <summary> |
50 | | - /// Copies the <see cref="IComponentFactory"/>s of the <see cref="ComponentFactoryCollection"/> to an <see cref="System.Array"/>, starting at a particular <see cref="System.Array"/> index. |
51 | | - /// </summary> |
52 | | - /// <param name="array">The one-dimensional <see cref="System.Array"/> that is the destination of the elements copied from <see cref="ComponentFactoryCollection"/>. The <see cref="System.Array"/> must have zero-based indexing.</param> |
53 | | - /// <param name="arrayIndex">The zero-based index in array at which copying begins.</param> |
54 | | - public void CopyTo(IComponentFactory[] array, int arrayIndex) => factories.CopyTo(array, arrayIndex); |
| 49 | + /// <summary> |
| 50 | + /// Copies the <see cref="IComponentFactory"/>s of the <see cref="ComponentFactoryCollection"/> to an <see cref="System.Array"/>, starting at a particular <see cref="System.Array"/> index. |
| 51 | + /// </summary> |
| 52 | + /// <param name="array">The one-dimensional <see cref="System.Array"/> that is the destination of the elements copied from <see cref="ComponentFactoryCollection"/>. The <see cref="System.Array"/> must have zero-based indexing.</param> |
| 53 | + /// <param name="arrayIndex">The zero-based index in array at which copying begins.</param> |
| 54 | + public void CopyTo(IComponentFactory[] array, int arrayIndex) => factories.CopyTo(array, arrayIndex); |
55 | 55 |
|
56 | | - /// <summary> |
57 | | - /// Returns an enumerator that iterates through the collection of <see cref="IComponentFactory"/>. |
58 | | - /// </summary> |
59 | | - /// <returns>An enumerator that can be used to iterate through the collection of <see cref="IComponentFactory"/>.</returns> |
60 | | - public IEnumerator<IComponentFactory> GetEnumerator() => factories.GetEnumerator(); |
| 56 | + /// <summary> |
| 57 | + /// Returns an enumerator that iterates through the collection of <see cref="IComponentFactory"/>. |
| 58 | + /// </summary> |
| 59 | + /// <returns>An enumerator that can be used to iterate through the collection of <see cref="IComponentFactory"/>.</returns> |
| 60 | + public IEnumerator<IComponentFactory> GetEnumerator() => factories.GetEnumerator(); |
61 | 61 |
|
62 | | - /// <summary> |
63 | | - /// Determines the index of a specific <see cref="IComponentFactory"/> in the <see cref="ComponentFactoryCollection"/>. |
64 | | - /// </summary> |
65 | | - /// <param name="item">The <see cref="IComponentFactory"/> to locate in the <see cref="ComponentFactoryCollection"/>..</param> |
66 | | - /// <returns>The index of <see cref="IComponentFactory"/> if found in the list; otherwise, -1.</returns> |
67 | | - public int IndexOf(IComponentFactory item) => factories.IndexOf(item); |
| 62 | + /// <summary> |
| 63 | + /// Determines the index of a specific <see cref="IComponentFactory"/> in the <see cref="ComponentFactoryCollection"/>. |
| 64 | + /// </summary> |
| 65 | + /// <param name="item">The <see cref="IComponentFactory"/> to locate in the <see cref="ComponentFactoryCollection"/>..</param> |
| 66 | + /// <returns>The index of <see cref="IComponentFactory"/> if found in the list; otherwise, -1.</returns> |
| 67 | + public int IndexOf(IComponentFactory item) => factories.IndexOf(item); |
68 | 68 |
|
69 | | - /// <summary> |
70 | | - /// Inserts an <see cref="IComponentFactory"/> to the <see cref="ComponentFactoryCollection"/> at the specified index. |
71 | | - /// </summary> |
72 | | - /// <param name="index">The zero-based index at which <see cref="IComponentFactory"/> should be inserted.</param> |
73 | | - /// <param name="item">The <see cref="IComponentFactory"/> to insert into the <see cref="ComponentFactoryCollection"/>.</param> |
74 | | - public void Insert(int index, IComponentFactory item) => factories.Insert(index, item); |
| 69 | + /// <summary> |
| 70 | + /// Inserts an <see cref="IComponentFactory"/> to the <see cref="ComponentFactoryCollection"/> at the specified index. |
| 71 | + /// </summary> |
| 72 | + /// <param name="index">The zero-based index at which <see cref="IComponentFactory"/> should be inserted.</param> |
| 73 | + /// <param name="item">The <see cref="IComponentFactory"/> to insert into the <see cref="ComponentFactoryCollection"/>.</param> |
| 74 | + public void Insert(int index, IComponentFactory item) => factories.Insert(index, item); |
75 | 75 |
|
76 | | - /// <summary> |
77 | | - /// Removes the first occurrence of a specific <see cref="IComponentFactory"/> from the <see cref="ComponentFactoryCollection"/>. |
78 | | - /// </summary> |
79 | | - /// <param name="item">The <see cref="IComponentFactory"/> to remove from the <see cref="ComponentFactoryCollection"/>.</param> |
80 | | - /// <returns>true if <see cref="IComponentFactory"/> was successfully removed from the <see cref="ComponentFactoryCollection"/>; otherwise, false. This method also returns false if <see cref="IComponentFactory"/> is not found in the original <see cref="ComponentFactoryCollection"/>.</returns> |
81 | | - public bool Remove(IComponentFactory item) => factories.Remove(item); |
| 76 | + /// <summary> |
| 77 | + /// Removes the first occurrence of a specific <see cref="IComponentFactory"/> from the <see cref="ComponentFactoryCollection"/>. |
| 78 | + /// </summary> |
| 79 | + /// <param name="item">The <see cref="IComponentFactory"/> to remove from the <see cref="ComponentFactoryCollection"/>.</param> |
| 80 | + /// <returns>true if <see cref="IComponentFactory"/> was successfully removed from the <see cref="ComponentFactoryCollection"/>; otherwise, false. This method also returns false if <see cref="IComponentFactory"/> is not found in the original <see cref="ComponentFactoryCollection"/>.</returns> |
| 81 | + public bool Remove(IComponentFactory item) => factories.Remove(item); |
82 | 82 |
|
83 | | - /// <summary> |
84 | | - /// Removes the <see cref="ComponentFactoryCollection"/> <see cref="IComponentFactory"/> at the specified index. |
85 | | - /// </summary> |
86 | | - /// <param name="index">The zero-based index of the <see cref="IComponentFactory"/> to remove.</param> |
87 | | - public void RemoveAt(int index) => factories.RemoveAt(index); |
| 83 | + /// <summary> |
| 84 | + /// Removes the <see cref="ComponentFactoryCollection"/> <see cref="IComponentFactory"/> at the specified index. |
| 85 | + /// </summary> |
| 86 | + /// <param name="index">The zero-based index of the <see cref="IComponentFactory"/> to remove.</param> |
| 87 | + public void RemoveAt(int index) => factories.RemoveAt(index); |
88 | 88 |
|
89 | | - /// <summary> |
90 | | - /// Returns an enumerator that iterates through a <see cref="ComponentFactoryCollection"/>. |
91 | | - /// </summary> |
92 | | - /// <returns>An <see cref="IEnumerator"/> object that can be used to iterate through the <see cref="ComponentFactoryCollection"/>.</returns> |
93 | | - IEnumerator IEnumerable.GetEnumerator() => ((IEnumerable)factories).GetEnumerator(); |
94 | | - } |
| 89 | + /// <summary> |
| 90 | + /// Returns an enumerator that iterates through a <see cref="ComponentFactoryCollection"/>. |
| 91 | + /// </summary> |
| 92 | + /// <returns>An <see cref="IEnumerator"/> object that can be used to iterate through the <see cref="ComponentFactoryCollection"/>.</returns> |
| 93 | + IEnumerator IEnumerable.GetEnumerator() => ((IEnumerable)factories).GetEnumerator(); |
95 | 94 | } |
96 | 95 | #endif |
0 commit comments