Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
TextElementEnumerator.cs
Go to the documentation of this file.
1
using
System.Collections
;
2
using
System.Text.Unicode
;
3
4
namespace
System.Globalization
;
5
6
public
class
TextElementEnumerator
:
IEnumerator
7
{
8
private
readonly
string
_str
;
9
10
private
readonly
int
_strStartIndex
;
11
12
private
int
_currentTextElementOffset
;
13
14
private
int
_currentTextElementLength
;
15
16
private
string
_currentTextElementSubstr
;
17
18
public
object
Current
=>
GetTextElement
();
19
20
public
int
ElementIndex
21
{
22
get
23
{
24
if
(
_currentTextElementOffset
>=
_str
.Length)
25
{
26
throw
new
InvalidOperationException
(
SR
.
InvalidOperation_EnumOpCantHappen
);
27
}
28
return
_currentTextElementOffset
-
_strStartIndex
;
29
}
30
}
31
32
internal
TextElementEnumerator
(
string
str
,
int
startIndex
)
33
{
34
_str
=
str
;
35
_strStartIndex
=
startIndex
;
36
Reset
();
37
}
38
39
public
bool
MoveNext
()
40
{
41
_currentTextElementSubstr
=
null
;
42
int
num = (
_currentTextElementOffset
+=
_currentTextElementLength
);
43
_currentTextElementLength
= 0;
44
if
(num >=
_str
.Length)
45
{
46
return
false
;
47
}
48
_currentTextElementLength
=
TextSegmentationUtility
.
GetLengthOfFirstUtf16ExtendedGraphemeCluster
(
_str
.AsSpan(num));
49
return
true
;
50
}
51
52
public
string
GetTextElement
()
53
{
54
string
text
=
_currentTextElementSubstr
;
55
if
(
text
==
null
)
56
{
57
if
(
_currentTextElementOffset
>=
_str
.Length)
58
{
59
throw
new
InvalidOperationException
(
SR
.
InvalidOperation_EnumOpCantHappen
);
60
}
61
text
= (
_currentTextElementSubstr
=
_str
.Substring(
_currentTextElementOffset
,
_currentTextElementLength
));
62
}
63
return
text
;
64
}
65
66
public
void
Reset
()
67
{
68
_currentTextElementOffset
=
_str
.Length;
69
_currentTextElementLength
=
_strStartIndex
-
_str
.Length;
70
_currentTextElementSubstr
=
null
;
71
}
72
}
System.Globalization.TextElementEnumerator.Current
object Current
Definition
TextElementEnumerator.cs:18
System.Globalization.TextElementEnumerator.Reset
void Reset()
Definition
TextElementEnumerator.cs:66
System.Globalization.TextElementEnumerator._str
readonly string _str
Definition
TextElementEnumerator.cs:8
System.Globalization.TextElementEnumerator._currentTextElementLength
int _currentTextElementLength
Definition
TextElementEnumerator.cs:14
System.Globalization.TextElementEnumerator.MoveNext
bool MoveNext()
Definition
TextElementEnumerator.cs:39
System.Globalization.TextElementEnumerator._currentTextElementSubstr
string _currentTextElementSubstr
Definition
TextElementEnumerator.cs:16
System.Globalization.TextElementEnumerator._strStartIndex
readonly int _strStartIndex
Definition
TextElementEnumerator.cs:10
System.Globalization.TextElementEnumerator.TextElementEnumerator
TextElementEnumerator(string str, int startIndex)
Definition
TextElementEnumerator.cs:32
System.Globalization.TextElementEnumerator.ElementIndex
int ElementIndex
Definition
TextElementEnumerator.cs:21
System.Globalization.TextElementEnumerator._currentTextElementOffset
int _currentTextElementOffset
Definition
TextElementEnumerator.cs:12
System.Globalization.TextElementEnumerator.GetTextElement
string GetTextElement()
Definition
TextElementEnumerator.cs:52
System.Globalization.TextElementEnumerator
Definition
TextElementEnumerator.cs:7
System.InvalidOperationException
Definition
InvalidOperationException.cs:9
System.SR.InvalidOperation_EnumOpCantHappen
static string InvalidOperation_EnumOpCantHappen
Definition
SR.cs:48
System.SR
Definition
SR.cs:7
System.Text.Unicode.TextSegmentationUtility.GetLengthOfFirstUtf16ExtendedGraphemeCluster
static int GetLengthOfFirstUtf16ExtendedGraphemeCluster(ReadOnlySpan< char > input)
Definition
TextSegmentationUtility.cs:145
System.Text.Unicode.TextSegmentationUtility
Definition
TextSegmentationUtility.cs:8
System.Collections.IEnumerator
Definition
IEnumerator.cs:4
System.Collections
Definition
BlockingCollection.cs:8
System.Globalization
Definition
Calendar.cs:1
System.Text.Unicode
Definition
GraphemeClusterBreakType.cs:1
System.ExceptionArgument.startIndex
@ startIndex
System.ExceptionArgument.text
@ text
System.ExceptionArgument.str
@ str
source
System.Private.CoreLib
System.Globalization
TextElementEnumerator.cs
Generated by
1.10.0