Uri.IsLoopback プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
指定した Uri がローカル ホストを参照するかどうかを示す値を取得します。
public:
property bool IsLoopback { bool get(); };
public bool IsLoopback { get; }
member this.IsLoopback : bool
Public ReadOnly Property IsLoopback As Boolean
プロパティ値
true この Uri がローカル ホストを参照する場合は。それ以外の場合は false。
例外
このインスタンスは相対 URI を表し、このプロパティは絶対 URI に対してのみ有効です。
例
次の例では、 Uri インスタンスを作成し、ローカル ホストを参照するかどうかを決定します。
Uri uriAddress2 = new Uri("file://server/filename.ext");
Console.WriteLine(uriAddress2.LocalPath);
Console.WriteLine("Uri {0} a UNC path", uriAddress2.IsUnc ? "is" : "is not");
Console.WriteLine("Uri {0} a local host", uriAddress2.IsLoopback ? "is" : "is not");
Console.WriteLine("Uri {0} a file", uriAddress2.IsFile ? "is" : "is not");
// The example displays the following output:
// \\server\filename.ext
// Uri is a UNC path
// Uri is not a local host
// Uri is a file
let uriAddress2 = Uri "file://server/filename.ext"
printfn $"{uriAddress2.LocalPath}"
printfn $"""Uri {if uriAddress2.IsUnc then "is" else "is not"} a UNC path"""
printfn $"""Uri {if uriAddress2.IsLoopback then "is" else "is not"} a local host"""
printfn $"""Uri {if uriAddress2.IsFile then "is" else "is not"} a file"""
// The example displays the following output:
// \\server\filename.ext
// Uri is a UNC path
// Uri is not a local host
// Uri is a file
Dim uriAddress2 As New Uri("file://server/filename.ext")
Console.WriteLine(uriAddress2.LocalPath)
Console.WriteLine("Uri {0} a UNC path", IIf(uriAddress2.IsUnc, "is", "is not")) 'TODO: For performance reasons this should be changed to nested IF statements
Console.WriteLine("Uri {0} a local host", IIf(uriAddress2.IsLoopback, "is", "is not")) 'TODO: For performance reasons this should be changed to nested IF statements
Console.WriteLine("Uri {0} a file", IIf(uriAddress2.IsFile, "is", "is not")) 'TODO: For performance reasons this should be changed to nested IF statements
' The example displays the following output:
' \\server\filename.ext
' Uri is a UNC path
' Uri is not a local host
' Uri is a file
注釈
IsLoopback は、このインスタンスの作成時に指定された URI が 127.0.0.1、ループバック、または localhost であった場合、または URI がホスト情報 (file:///c:Dir/file.txtなど) を指定しなかった場合に、 true を返します。 他のすべての URI は falseを返します。