Uri.IsBaseOf(Uri) Yöntem

Tanım

Geçerli Uri örneğin belirtilen Uri örneğin temeli olup olmadığını belirler.

public:
 bool IsBaseOf(Uri ^ uri);
public bool IsBaseOf (Uri uri);
member this.IsBaseOf : Uri -> bool
Public Function IsBaseOf (uri As Uri) As Boolean

Parametreler

uri
Uri

Test için belirtilen URI.

Döndürülenler

Boolean

true geçerli Uri örnek öğesinin temeliyse uri, aksi takdirde , false.

Özel durumlar

uri, null değeridir.

Örnekler

Bu örnek, bir Uri temel Uri örneği temsil eden bir örnek oluşturur. Ardından bir dizeden ikinci Uri bir örnek oluşturur. Temel örneğin ikinci örneğin temeli olup olmadığını belirlemek için çağırır IsBaseOf . Sonuç konsola yazılır.

// Create a base Uri.
Uri^ baseUri = gcnew Uri( "http://www.contoso.com/" );

// Create a new Uri from a string.
Uri^ uriAddress = gcnew 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.
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

Açıklamalar

IsBaseOf , bu URI'nin belirtilen için bir temel olup olmadığını belirlemek üzere geçerli Uri örneği belirtilen Uri Uribir ile karşılaştırmak için kullanılır. Bir temel ilişkiyi belirlemek için iki Uri nesne karşılaştırılırken, kullanıcı bilgileri (UserInfo) değerlendirilmez. İki URI'yi (uri1 ve uri2) karşılaştırırken, son eğik çizgiden (/) sonra uri2'deki her şeyi yoksayarsanız, uri1 uri2'nin tabanıdır. Temel URI olarak kullanıldığında http://host/path/path/file?query , aşağıdaki tabloda diğer URI'ler için temel olup olmadığı gösterilmektedir.

URI http://host/path/path/file?query temel
http://host/path/path/file/ evet
http://host/path/path/#fragment evet
http://host/path/path/MoreDir/" evet
http://host/path/path/OtherFile?Query evet
http://host/path/path/ evet
http://host/path/path/file evet
http://host/path/path hayır
http://host/path/path?query hayır
http://host/path/path#Fragment hayır
http://host/path/path2/ hayır
://host/path/path2/MoreDir hayır
http://host/path/File hayır

Şunlara uygulanır