public override string ToString() { if (_username.Length == 0 && _password.Length > 0) { throw new UriFormatException(SR.net_uri_BadUserPassword); } if (_scheme.Length != 0) { UriParser syntax = UriParser.GetSyntax(_scheme); if (syntax != null) { _schemeDelimiter = syntax.InFact(UriSyntaxFlags.MustHaveAuthority) || (_host.Length != 0 && syntax.NotAny(UriSyntaxFlags.MailToLikeUri) && syntax.InFact(UriSyntaxFlags.OptionalAuthority)) ? Uri.SchemeDelimiter : ":"; } else { _schemeDelimiter = _host.Length != 0 ? Uri.SchemeDelimiter : ":"; } } string result = _scheme.Length != 0 ? (_scheme + _schemeDelimiter) : string.Empty; return(result + _username + ((_password.Length > 0) ? (":" + _password) : string.Empty) + ((_username.Length > 0) ? "@" : string.Empty) + _host + (((_port != -1) && (_host.Length > 0)) ? (":" + _port) : string.Empty) + (((_host.Length > 0) && (_path.Length != 0) && (_path[0] != '/')) ? "/" : string.Empty) + _path + _query + _fragment); }
// // Is a Uri scheme known to System.Uri? // public static bool IsKnownScheme(string schemeName) { ArgumentNullException.ThrowIfNull(schemeName); if (!Uri.CheckSchemeName(schemeName)) { throw new ArgumentOutOfRangeException(nameof(schemeName)); } UriParser?syntax = UriParser.GetSyntax(schemeName.ToLowerInvariant()); return(syntax != null && syntax.NotAny(UriSyntaxFlags.V1_UnknownUri)); }
// // Is a Uri scheme known to System.Uri? // public static bool IsKnownScheme(string schemeName) { if (schemeName == null) { throw new ArgumentNullException("schemeName"); } if (!Uri.CheckSchemeName(schemeName)) { throw new ArgumentOutOfRangeException("schemeName"); } UriParser syntax = UriParser.GetSyntax(schemeName.ToLower(CultureInfo.InvariantCulture)); return(syntax != null && syntax.NotAny(UriSyntaxFlags.V1_UnknownUri)); }
public override string ToString() { if ((this.m_username.Length == 0) && (this.m_password.Length > 0)) { throw new UriFormatException(SR.GetString("net_uri_BadUserPassword")); } if (this.m_scheme.Length != 0) { UriParser syntax = UriParser.GetSyntax(this.m_scheme); if (syntax != null) { this.m_schemeDelimiter = (syntax.InFact(UriSyntaxFlags.MustHaveAuthority) || (((this.m_host.Length != 0) && syntax.NotAny(UriSyntaxFlags.MailToLikeUri)) && syntax.InFact(UriSyntaxFlags.OptionalAuthority))) ? System.Uri.SchemeDelimiter : ":"; } else { this.m_schemeDelimiter = (this.m_host.Length != 0) ? System.Uri.SchemeDelimiter : ":"; } } string str = (this.m_scheme.Length != 0) ? (this.m_scheme + this.m_schemeDelimiter) : string.Empty; string[] strArray = new string[] { str, this.m_username, (this.m_password.Length > 0) ? (":" + this.m_password) : string.Empty, (this.m_username.Length > 0) ? "@" : string.Empty, this.m_host, ((this.m_port != -1) && (this.m_host.Length > 0)) ? (":" + this.m_port) : string.Empty, (((this.m_host.Length > 0) && (this.m_path.Length != 0)) && (this.m_path[0] != '/')) ? "/" : string.Empty, this.m_path, this.m_query, this.m_fragment }; return(string.Concat(strArray)); }