Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ToString()

override string System.UriBuilder.ToString ( )
inline

Definition at line 303 of file UriBuilder.cs.

304 {
305 if (UserName.Length == 0 && Password.Length != 0)
306 {
307 throw new UriFormatException(System.SR.net_uri_BadUserPassword);
308 }
309 Span<char> initialBuffer = stackalloc char[512];
310 System.Text.ValueStringBuilder valueStringBuilder = new System.Text.ValueStringBuilder(initialBuffer);
311 string scheme = Scheme;
312 string host = Host;
313 if (scheme.Length != 0)
314 {
315 UriParser syntax = UriParser.GetSyntax(scheme);
316 string s = ((syntax != null) ? ((syntax.InFact(UriSyntaxFlags.MustHaveAuthority) || (host.Length != 0 && syntax.NotAny(UriSyntaxFlags.MailToLikeUri) && syntax.InFact(UriSyntaxFlags.OptionalAuthority))) ? System.Uri.SchemeDelimiter : ":") : ((host.Length == 0) ? ":" : System.Uri.SchemeDelimiter));
317 valueStringBuilder.Append(scheme);
318 valueStringBuilder.Append(s);
319 }
320 string userName = UserName;
321 if (userName.Length != 0)
322 {
323 valueStringBuilder.Append(userName);
324 string password = Password;
325 if (password.Length != 0)
326 {
327 valueStringBuilder.Append(':');
328 valueStringBuilder.Append(password);
329 }
330 valueStringBuilder.Append('@');
331 }
332 if (host.Length != 0)
333 {
334 valueStringBuilder.Append(host);
335 if (_port != -1)
336 {
337 valueStringBuilder.Append(':');
338 int charsWritten;
339 bool flag = _port.TryFormat(valueStringBuilder.AppendSpan(5), out charsWritten);
340 valueStringBuilder.Length -= 5 - charsWritten;
341 }
342 }
343 string path = Path;
344 if (path.Length != 0)
345 {
346 if (!path.StartsWith('/') && host.Length != 0)
347 {
348 valueStringBuilder.Append('/');
349 }
350 valueStringBuilder.Append(path);
351 }
352 valueStringBuilder.Append(Query);
353 valueStringBuilder.Append(Fragment);
354 return valueStringBuilder.ToString();
355 }
static string net_uri_BadUserPassword
Definition SR.cs:32
Definition SR.cs:7
Span< char > AppendSpan(int length)

References System.UriBuilder._port, System.Text.ValueStringBuilder.Append(), System.Text.ValueStringBuilder.AppendSpan(), System.UriBuilder.Fragment, System.UriParser.GetSyntax(), System.UriBuilder.Host, System.UriParser.InFact(), System.SR.net_uri_BadUserPassword, System.UriParser.NotAny(), System.UriBuilder.Password, System.UriBuilder.Path, System.UriBuilder.Query, System.s, System.UriBuilder.Scheme, System.Uri.SchemeDelimiter, System.Text.ValueStringBuilder.ToString(), and System.UriBuilder.UserName.