-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMySpecialCollection.cs
More file actions
53 lines (44 loc) · 1.5 KB
/
MySpecialCollection.cs
File metadata and controls
53 lines (44 loc) · 1.5 KB
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
/******************************************************************/
/// <copyright file="MySpecialCollection.cs" company="Sharpro">
/// Copyright (c) 2018 All Rights Reserved
/// </copyright>
/// <author>Jarosław Mielewski</author>
/// <date>16:08</date>
/******************************************************************/
namespace _2_interfejsy_kolekcje
{
using System.Collections;
using System.Collections.Generic;
using System.Text;
public partial class MySpecialCollection : IEnumerable<IElement>
{
private IEnumerator _enumerator;
public MySpecialCollection()
{
_enumerator = new ElementEnumerator();
}
public IEnumerator<IElement> GetEnumerator()
{
return new ElementEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return _enumerator;
}
public override string ToString()
{
StringBuilder collectionPreview = new StringBuilder();
ElementEnumerator enumerator = GetEnumerator() as ElementEnumerator;
if(!enumerator.MoveNext())
{
return "SpecialCollection.Empty";
}
enumerator.MovePrevious();
while(enumerator.MoveNext())
{
collectionPreview.AppendFormat("[{0}]", enumerator.Current.Name);
}
return collectionPreview.ToString();
}
}
}