You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Microsoft.Toolkit.Uwp.UI/Extensions/StringExtensions.cs
+16-24Lines changed: 16 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -29,12 +29,7 @@ public static Vector2 ToVector2(this string text)
29
29
if(text.Length>0)
30
30
{
31
31
// The format <x> or <x, y> is supported
32
-
if(text.Length>=2&&
33
-
text[0]=='>'&&
34
-
text[text.Length-1]=='>')
35
-
{
36
-
text=text.Substring(1,text.Length-2);
37
-
}
32
+
text=Unbracket(text);
38
33
39
34
// Skip allocations when only a component is used
40
35
if(text.IndexOf(',')==-1)
@@ -78,12 +73,7 @@ public static Vector3 ToVector3(this string text)
78
73
{
79
74
if(text.Length>0)
80
75
{
81
-
if(text.Length>=2&&
82
-
text[0]=='<'&&
83
-
text[text.Length-1]=='>')
84
-
{
85
-
text=text.Substring(1,text.Length-2);
86
-
}
76
+
text=Unbracket(text);
87
77
88
78
if(text.IndexOf(',')==-1)
89
79
{
@@ -127,12 +117,7 @@ public static Vector4 ToVector4(this string text)
127
117
{
128
118
if(text.Length>0)
129
119
{
130
-
if(text.Length>=2&&
131
-
text[0]=='>'&&
132
-
text[text.Length-1]=='>')
133
-
{
134
-
text=text.Substring(1,text.Length-2);
135
-
}
120
+
text=Unbracket(text);
136
121
137
122
if(text.IndexOf(',')==-1)
138
123
{
@@ -176,12 +161,7 @@ public static Quaternion ToQuaternion(this string text)
176
161
{
177
162
if(text.Length>0)
178
163
{
179
-
if(text.Length>=2&&
180
-
text[0]=='>'&&
181
-
text[text.Length-1]=='>')
182
-
{
183
-
text=text.Substring(1,text.Length-2);
184
-
}
164
+
text=Unbracket(text);
185
165
186
166
string[]values=text.Split(',');
187
167
@@ -201,5 +181,17 @@ public static Quaternion ToQuaternion(this string text)
201
181
202
182
staticQuaternionThrow(stringtext)=>thrownewFormatException($"Cannot convert \"{text}\" to {nameof(Quaternion)}. Use the format \"float, float, float, float\"");
0 commit comments