Files
2026-06-04 11:42:34 +02:00

431 lines
15 KiB
C#

using System;
using System.Text;
namespace System
{
/// <summary>Provides a custom constructor for uniform resource identifiers (URIs) and modifies URIs for the <see cref="T:System.Uri" /> class.</summary>
/// <filterpriority>2</filterpriority>
// Token: 0x020002FD RID: 765
public class UriBuilder
{
/// <summary>Initializes a new instance of the <see cref="T:System.UriBuilder" /> class.</summary>
// Token: 0x06001BB9 RID: 7097 RVA: 0x00067C4C File Offset: 0x00065E4C
public UriBuilder()
: this(global::System.Uri.UriSchemeHttp, "localhost")
{
}
/// <summary>Initializes a new instance of the <see cref="T:System.UriBuilder" /> class with the specified URI.</summary>
/// <param name="uri">A URI string. </param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="uri" /> is null. </exception>
/// <exception cref="T:System.UriFormatException">
/// <paramref name="uri" /> is a zero length string or contains only spaces.-or- The parsing routine detected a scheme in an invalid form.-or- The parser detected more than two consecutive slashes in a URI that does not use the "file" scheme.-or- <paramref name="uri" /> is not a valid URI. </exception>
// Token: 0x06001BBA RID: 7098 RVA: 0x00067C60 File Offset: 0x00065E60
public UriBuilder(string uri)
: this(new global::System.Uri(uri))
{
}
/// <summary>Initializes a new instance of the <see cref="T:System.UriBuilder" /> class with the specified <see cref="T:System.Uri" /> instance.</summary>
/// <param name="uri">An instance of the <see cref="T:System.Uri" /> class. </param>
/// <exception cref="T:System.NullReferenceException">
/// <paramref name="uri" /> is null. </exception>
// Token: 0x06001BBB RID: 7099 RVA: 0x00067C70 File Offset: 0x00065E70
public UriBuilder(global::System.Uri uri)
{
this.scheme = uri.Scheme;
this.host = uri.Host;
this.port = uri.Port;
this.path = uri.AbsolutePath;
this.query = uri.Query;
this.fragment = uri.Fragment;
this.username = uri.UserInfo;
int num = this.username.IndexOf(':');
if (num != -1)
{
this.password = this.username.Substring(num + 1);
this.username = this.username.Substring(0, num);
}
else
{
this.password = string.Empty;
}
this.modified = true;
}
/// <summary>Initializes a new instance of the <see cref="T:System.UriBuilder" /> class with the specified scheme and host.</summary>
/// <param name="schemeName">An Internet access protocol. </param>
/// <param name="hostName">A DNS-style domain name or IP address. </param>
// Token: 0x06001BBC RID: 7100 RVA: 0x00067D2C File Offset: 0x00065F2C
public UriBuilder(string schemeName, string hostName)
{
this.Scheme = schemeName;
this.Host = hostName;
this.port = -1;
this.Path = string.Empty;
this.query = string.Empty;
this.fragment = string.Empty;
this.username = string.Empty;
this.password = string.Empty;
this.modified = true;
}
/// <summary>Initializes a new instance of the <see cref="T:System.UriBuilder" /> class with the specified scheme, host, and port.</summary>
/// <param name="scheme">An Internet access protocol. </param>
/// <param name="host">A DNS-style domain name or IP address. </param>
/// <param name="portNumber">An IP port number for the service. </param>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="portNumber" /> is less than 0 or greater than 65,535. </exception>
// Token: 0x06001BBD RID: 7101 RVA: 0x00067D94 File Offset: 0x00065F94
public UriBuilder(string scheme, string host, int portNumber)
: this(scheme, host)
{
this.Port = portNumber;
}
/// <summary>Initializes a new instance of the <see cref="T:System.UriBuilder" /> class with the specified scheme, host, port number, and path.</summary>
/// <param name="scheme">An Internet access protocol. </param>
/// <param name="host">A DNS-style domain name or IP address. </param>
/// <param name="port">An IP port number for the service. </param>
/// <param name="pathValue">The path to the Internet resource. </param>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="port" /> is less than 0 or greater than 65,535. </exception>
// Token: 0x06001BBE RID: 7102 RVA: 0x00067DA8 File Offset: 0x00065FA8
public UriBuilder(string scheme, string host, int port, string pathValue)
: this(scheme, host, port)
{
this.Path = pathValue;
}
/// <summary>Initializes a new instance of the <see cref="T:System.UriBuilder" /> class with the specified scheme, host, port number, path and query string or fragment identifier.</summary>
/// <param name="scheme">An Internet access protocol. </param>
/// <param name="host">A DNS-style domain name or IP address. </param>
/// <param name="port">An IP port number for the service. </param>
/// <param name="path">The path to the Internet resource. </param>
/// <param name="extraValue">A query string or fragment identifier. </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="extraValue" /> is neither null nor <see cref="F:System.String.Empty" />, nor does a valid fragment identifier begin with a number sign (#), nor a valid query string begin with a question mark (?). </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="port" /> is less than 0 or greater than 65,535. </exception>
// Token: 0x06001BBF RID: 7103 RVA: 0x00067DBC File Offset: 0x00065FBC
public UriBuilder(string scheme, string host, int port, string pathValue, string extraValue)
: this(scheme, host, port, pathValue)
{
if (extraValue == null || extraValue.Length == 0)
{
return;
}
if (extraValue[0] == '#')
{
this.Fragment = extraValue.Remove(0, 1);
}
else
{
if (extraValue[0] != '?')
{
throw new ArgumentException("extraValue");
}
this.Query = extraValue.Remove(0, 1);
}
}
/// <summary>Gets or sets the fragment portion of the URI.</summary>
/// <returns>The fragment portion of the URI. The fragment identifier ("#") is added to the beginning of the fragment.</returns>
/// <filterpriority>2</filterpriority>
// Token: 0x17000869 RID: 2153
// (get) Token: 0x06001BC0 RID: 7104 RVA: 0x00067E3C File Offset: 0x0006603C
// (set) Token: 0x06001BC1 RID: 7105 RVA: 0x00067E44 File Offset: 0x00066044
public string Fragment
{
get
{
return this.fragment;
}
set
{
this.fragment = value;
if (this.fragment == null)
{
this.fragment = string.Empty;
}
else if (this.fragment.Length > 0)
{
this.fragment = "#" + value.Replace("%23", "#");
}
this.modified = true;
}
}
/// <summary>Gets or sets the Domain Name System (DNS) host name or IP address of a server.</summary>
/// <returns>The DNS host name or IP address of the server.</returns>
/// <filterpriority>1</filterpriority>
// Token: 0x1700086A RID: 2154
// (get) Token: 0x06001BC2 RID: 7106 RVA: 0x00067EAC File Offset: 0x000660AC
// (set) Token: 0x06001BC3 RID: 7107 RVA: 0x00067EB4 File Offset: 0x000660B4
public string Host
{
get
{
return this.host;
}
set
{
this.host = ((value != null) ? value : string.Empty);
this.modified = true;
}
}
/// <summary>Gets or sets the password associated with the user that accesses the URI.</summary>
/// <returns>The password of the user that accesses the URI.</returns>
/// <filterpriority>1</filterpriority>
// Token: 0x1700086B RID: 2155
// (get) Token: 0x06001BC4 RID: 7108 RVA: 0x00067ED4 File Offset: 0x000660D4
// (set) Token: 0x06001BC5 RID: 7109 RVA: 0x00067EDC File Offset: 0x000660DC
public string Password
{
get
{
return this.password;
}
set
{
this.password = ((value != null) ? value : string.Empty);
this.modified = true;
}
}
/// <summary>Gets or sets the path to the resource referenced by the URI.</summary>
/// <returns>The path to the resource referenced by the URI.</returns>
/// <filterpriority>1</filterpriority>
// Token: 0x1700086C RID: 2156
// (get) Token: 0x06001BC6 RID: 7110 RVA: 0x00067EFC File Offset: 0x000660FC
// (set) Token: 0x06001BC7 RID: 7111 RVA: 0x00067F04 File Offset: 0x00066104
public string Path
{
get
{
return this.path;
}
set
{
if (value == null || value.Length == 0)
{
this.path = "/";
}
else
{
this.path = global::System.Uri.EscapeString(value.Replace('\\', '/'), false, true, true);
}
this.modified = true;
}
}
/// <summary>Gets or sets the port number of the URI.</summary>
/// <returns>The port number of the URI.</returns>
/// <exception cref="T:System.ArgumentOutOfRangeException">The port cannot be set to a value less than 0 or greater than 65,535. </exception>
/// <filterpriority>1</filterpriority>
// Token: 0x1700086D RID: 2157
// (get) Token: 0x06001BC8 RID: 7112 RVA: 0x00067F54 File Offset: 0x00066154
// (set) Token: 0x06001BC9 RID: 7113 RVA: 0x00067F5C File Offset: 0x0006615C
public int Port
{
get
{
return this.port;
}
set
{
if (value < -1)
{
throw new ArgumentOutOfRangeException("value");
}
this.port = value;
this.modified = true;
}
}
/// <summary>Gets or sets any query information included in the URI.</summary>
/// <returns>The query information included in the URI.</returns>
/// <filterpriority>1</filterpriority>
// Token: 0x1700086E RID: 2158
// (get) Token: 0x06001BCA RID: 7114 RVA: 0x00067F8C File Offset: 0x0006618C
// (set) Token: 0x06001BCB RID: 7115 RVA: 0x00067F94 File Offset: 0x00066194
public string Query
{
get
{
return this.query;
}
set
{
if (value == null || value.Length == 0)
{
this.query = string.Empty;
}
else
{
this.query = "?" + value;
}
this.modified = true;
}
}
/// <summary>Gets or sets the scheme name of the URI.</summary>
/// <returns>The scheme of the URI.</returns>
/// <exception cref="T:System.ArgumentOutOfRangeException">The scheme cannot be set to an invalid scheme name. </exception>
/// <filterpriority>1</filterpriority>
// Token: 0x1700086F RID: 2159
// (get) Token: 0x06001BCC RID: 7116 RVA: 0x00067FD0 File Offset: 0x000661D0
// (set) Token: 0x06001BCD RID: 7117 RVA: 0x00067FD8 File Offset: 0x000661D8
public string Scheme
{
get
{
return this.scheme;
}
set
{
if (value == null)
{
value = string.Empty;
}
int num = value.IndexOf(':');
if (num != -1)
{
value = value.Substring(0, num);
}
this.scheme = value.ToLower();
this.modified = true;
}
}
/// <summary>Gets the <see cref="T:System.Uri" /> instance constructed by the specified <see cref="T:System.UriBuilder" /> instance.</summary>
/// <returns>A <see cref="T:System.Uri" /> that contains the URI constructed by the <see cref="T:System.UriBuilder" />.</returns>
/// <exception cref="T:System.UriFormatException">The URI constructed by the <see cref="T:System.UriBuilder" /> properties is invalid. </exception>
/// <filterpriority>1</filterpriority>
// Token: 0x17000870 RID: 2160
// (get) Token: 0x06001BCE RID: 7118 RVA: 0x00068020 File Offset: 0x00066220
public global::System.Uri Uri
{
get
{
if (!this.modified)
{
return this.uri;
}
this.uri = new global::System.Uri(this.ToString(), true);
this.modified = false;
return this.uri;
}
}
/// <summary>The user name associated with the user that accesses the URI.</summary>
/// <returns>The user name of the user that accesses the URI.</returns>
/// <filterpriority>1</filterpriority>
// Token: 0x17000871 RID: 2161
// (get) Token: 0x06001BCF RID: 7119 RVA: 0x00068054 File Offset: 0x00066254
// (set) Token: 0x06001BD0 RID: 7120 RVA: 0x0006805C File Offset: 0x0006625C
public string UserName
{
get
{
return this.username;
}
set
{
this.username = ((value != null) ? value : string.Empty);
this.modified = true;
}
}
/// <summary>Compares an existing <see cref="T:System.Uri" /> instance with the contents of the <see cref="T:System.UriBuilder" /> for equality.</summary>
/// <returns>true if <paramref name="rparam" /> represents the same <see cref="T:System.Uri" /> as the <see cref="T:System.Uri" /> constructed by this <see cref="T:System.UriBuilder" /> instance; otherwise, false.</returns>
/// <param name="rparam">The object to compare with the current instance. </param>
/// <filterpriority>2</filterpriority>
// Token: 0x06001BD1 RID: 7121 RVA: 0x0006807C File Offset: 0x0006627C
public override bool Equals(object rparam)
{
return rparam != null && this.Uri.Equals(rparam.ToString());
}
/// <summary>Returns the hash code for the URI.</summary>
/// <returns>The hash code generated for the URI.</returns>
/// <filterpriority>2</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x06001BD2 RID: 7122 RVA: 0x0006809C File Offset: 0x0006629C
public override int GetHashCode()
{
return this.Uri.GetHashCode();
}
/// <summary>Returns the display string for the specified <see cref="T:System.UriBuilder" /> instance.</summary>
/// <returns>The string that contains the unescaped display string of the <see cref="T:System.UriBuilder" />.</returns>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
/// </PermissionSet>
// Token: 0x06001BD3 RID: 7123 RVA: 0x000680AC File Offset: 0x000662AC
public override string ToString()
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append(this.scheme);
stringBuilder.Append("://");
if (this.username != string.Empty)
{
stringBuilder.Append(this.username);
if (this.password != string.Empty)
{
stringBuilder.Append(":" + this.password);
}
stringBuilder.Append('@');
}
stringBuilder.Append(this.host);
if (this.port > 0)
{
stringBuilder.Append(":" + this.port);
}
if (this.path != string.Empty && stringBuilder[stringBuilder.Length - 1] != '/' && this.path.Length > 0 && this.path[0] != '/')
{
stringBuilder.Append('/');
}
stringBuilder.Append(this.path);
stringBuilder.Append(this.query);
stringBuilder.Append(this.fragment);
return stringBuilder.ToString();
}
// Token: 0x04001610 RID: 5648
private string scheme;
// Token: 0x04001611 RID: 5649
private string host;
// Token: 0x04001612 RID: 5650
private int port;
// Token: 0x04001613 RID: 5651
private string path;
// Token: 0x04001614 RID: 5652
private string query;
// Token: 0x04001615 RID: 5653
private string fragment;
// Token: 0x04001616 RID: 5654
private string username;
// Token: 0x04001617 RID: 5655
private string password;
// Token: 0x04001618 RID: 5656
private global::System.Uri uri;
// Token: 0x04001619 RID: 5657
private bool modified;
}
}