-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSequence.cs
More file actions
46 lines (41 loc) · 1.24 KB
/
Copy pathSequence.cs
File metadata and controls
46 lines (41 loc) · 1.24 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Generator
{
public class Sequence : IGenerate
{
private List<IGenerate> _items;
private string _separator;
public Sequence(List<IGenerate> items, string separator = " ")
{
_items = items;
_separator = separator;
}
public string Generate()
{
StringBuilder sb = new StringBuilder();
sb.Append(_items[0].Generate());
for (int i = 1; i < _items.Count; i++)
{
sb.Append(_separator);
sb.Append(_items[i].Generate());
}
return sb.ToString();
}
public static Sequence operator +(Sequence a, Sequence b)
{
List<IGenerate> newlist = new List<IGenerate>(a._items);
newlist.Concat(b._items);
return new Sequence(newlist, a._separator);
}
public static Sequence operator +(Sequence a, IGenerate b)
{
List<IGenerate> newlist = new List<IGenerate>(a._items);
newlist.Add(b);
return new Sequence(newlist, a._separator);
}
}
}