Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
HeaderStringValues.cs
Go to the documentation of this file.
3
5
6public readonly struct HeaderStringValues : IReadOnlyCollection<string>, IEnumerable<string>, IEnumerable
7{
8 public struct Enumerator : IEnumerator<string>, IEnumerator, IDisposable
9 {
10 private readonly string[] _values;
11
12 private string _current;
13
14 private int _index;
15
16 public string Current => _current;
17
18 object IEnumerator.Current => Current;
19
20 internal Enumerator(object value)
21 {
22 if (value is string current)
23 {
24 _values = null;
25 _current = current;
26 }
27 else
28 {
29 _values = value as string[];
30 _current = null;
31 }
32 _index = 0;
33 }
34
35 public bool MoveNext()
36 {
37 int index = _index;
38 if (index < 0)
39 {
40 return false;
41 }
42 string[] values = _values;
43 if (values != null)
44 {
45 if ((uint)index < (uint)values.Length)
46 {
47 _index = index + 1;
49 return true;
50 }
51 _index = -1;
52 return false;
53 }
54 _index = -1;
55 return _current != null;
56 }
57
58 public void Dispose()
59 {
60 }
61
63 {
64 throw new NotSupportedException();
65 }
66 }
67
68 private readonly HeaderDescriptor _header;
69
70 private readonly object _value;
71
72 public int Count
73 {
74 get
75 {
76 object value = _value;
77 if (!(value is string))
78 {
79 if (value is string[] array)
80 {
81 return array.Length;
82 }
83 return 0;
84 }
85 return 1;
86 }
87 }
88
89 internal HeaderStringValues(HeaderDescriptor descriptor, string value)
90 {
91 _header = descriptor;
92 _value = value;
93 }
94
95 internal HeaderStringValues(HeaderDescriptor descriptor, string[] values)
96 {
97 _header = descriptor;
98 _value = values;
99 }
100
101 public override string ToString()
102 {
103 object value = _value;
104 if (!(value is string result))
105 {
106 if (value is string[] value2)
107 {
109 return string.Join((parser != null && parser.SupportsMultipleValues) ? parser.Separator : ", ", value2);
110 }
111 return string.Empty;
112 }
113 return result;
114 }
115
117 {
118 return new Enumerator(_value);
119 }
120
125
130}
new IEnumerator< T > GetEnumerator()
HeaderStringValues(HeaderDescriptor descriptor, string[] values)
HeaderStringValues(HeaderDescriptor descriptor, string value)