Uri.IsBaseOf(Uri) Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
public:
bool IsBaseOf(Uri ^ uri);
public bool IsBaseOf(Uri uri);
member this.IsBaseOf : Uri -> bool
Public Function IsBaseOf (uri As Uri) As Boolean
Parâmetros
- uri
- Uri
O URI especificado para testar.
Devoluções
true se a instância atual Uri for uma base de uri; caso contrário, false.
Exceções
uri é null.
Exemplos
Este exemplo cria uma Uri instância que representa uma instância base Uri . Depois, cria uma segunda Uri instância a partir de uma cadeia. Chama IsBaseOf para determinar se a instância base é a base da segunda instância. O resultado é escrito para a consola.
// Create a base Uri.
Uri baseUri = new Uri("http://www.contoso.com/");
// Create a new Uri from a string.
Uri uriAddress = new Uri("http://www.contoso.com/index.htm?date=today");
// Determine whether BaseUri is a base of UriAddress.
if (baseUri.IsBaseOf(uriAddress))
Console.WriteLine("{0} is the base of {1}", baseUri, uriAddress);
// Create a base Uri.
let baseUri = Uri "http://www.contoso.com/"
// Create a new Uri from a string.
let uriAddress = Uri "http://www.contoso.com/index.htm?date=today"
// Determine whether BaseUri is a base of UriAddress.
if baseUri.IsBaseOf uriAddress then
printfn $"{baseUri} is the base of {uriAddress}"
' Create a base Uri.
Dim baseUri As New Uri("http://www.contoso.com/")
' Create a new Uri from a string.
Dim uriAddress As New Uri("http://www.contoso.com/index.htm?date=today")
' Determine whether BaseUri is a base of UriAddress.
If baseUri.IsBaseOf(uriAddress) Then
Console.WriteLine("{0} is the base of {1}", baseUri, uriAddress)
End If
Observações
IsBaseOf é usado para comparar a instância atual Uri com um especificado Uri para determinar se este URI é uma base para o especificado Uri. Ao comparar dois Uri objetos para determinar uma relação base, a informação do utilizador (UserInfo) não é avaliada. Ao comparar duas URIs (uri1 e uri2), uri1 é a base de uri2 se, ao ignorar tudo em uri1 e uri2 após a última barra (/), uri2 começa exatamente com uri1. Usando http://host/path/path/file?query como URI base, a tabela seguinte mostra se é uma base para outros URIs.
| URI | http://host/path/path/file?query é a base de |
|---|---|
| http://host/path/path/file/ | sim |
| http://host/path/path/#fragment | sim |
| http://host/path/path/MoreDir/" | sim |
| http://host/path/path/OtherFile?Query | sim |
| http://host/path/path/ | sim |
| http://host/path/path/file | sim |
| http://host/path/path | Não |
| http://host/path/path?query | Não |
| http://host/path/path#Fragment | Não |
| http://host/path/path2/ | Não |
| ://host/path/path2/MoreDir | Não |
| http://host/path/File | Não |