UriTemplateMatch クラス

定義

UriTemplate インスタンスでの一致操作の結果を表すクラス。

public ref class UriTemplateMatch
public class UriTemplateMatch
type UriTemplateMatch = class
Public Class UriTemplateMatch
継承
UriTemplateMatch

次のコードは、 UriTemplateMatch クラスの使用方法を示しています。

UriTemplate template = new UriTemplate("weather/{state}/{city}?forecast=today");
Uri baseAddress = new Uri("http://localhost");
Uri fullUri = new Uri("http://localhost/weather/WA/Seattle?forecast=today");

Console.WriteLine("Matching {0} to {1}", template.ToString(), fullUri.ToString());

// Match a URI to a template
UriTemplateMatch results = template.Match(baseAddress, fullUri);
if (results != null)
{
    // BaseUri
    Console.WriteLine("BaseUri: {0}", results.BaseUri);

    Console.WriteLine("BoundVariables:");
    foreach (string variableName in results.BoundVariables.Keys)
    {
        Console.WriteLine("    {0}: {1}", variableName, results.BoundVariables[variableName]);
    }

    Console.WriteLine("QueryParameters:");
    foreach (string queryName in results.QueryParameters.Keys)
    {
        Console.WriteLine("    {0} : {1}", queryName, results.QueryParameters[queryName]);
    }
    Console.WriteLine();

    Console.WriteLine("RelativePathSegments:");
    foreach (string segment in results.RelativePathSegments)
    {
        Console.WriteLine("     {0}", segment);
    }
    Console.WriteLine();

    Console.WriteLine("RequestUri:");
    Console.WriteLine(results.RequestUri);

    Console.WriteLine("Template:");
    Console.WriteLine(results.Template);

    Console.WriteLine("WildcardPathSegments:");
    foreach (string segment in results.WildcardPathSegments)
    {
        Console.WriteLine("     {0}", segment);
    }
    Console.WriteLine();
}
Dim template As New UriTemplate("weather/{state}/{city}?forecast=today")
Dim baseAddress As New Uri("http://localhost")
Dim fullUri As New Uri("http://localhost/weather/WA/Seattle?forecast=today")

Console.WriteLine("Matching {0} to {1}", template.ToString(), fullUri.ToString())

'Match a URI to a template
Dim results As UriTemplateMatch = template.Match(baseAddress, fullUri)
If (results IsNot Nothing) Then

    'BaseUri
    Console.WriteLine("BaseUri: {0}", results.BaseUri)

    Console.WriteLine("BoundVariables:")
    For Each variableName As String In results.BoundVariables.Keys
        Console.WriteLine("    {0}: {1}", variableName, results.BoundVariables(variableName))
    Next

    Console.WriteLine("QueryParameters:")
    For Each queryName As String In results.QueryParameters.Keys
        Console.WriteLine("    {0} : {1}", queryName, results.QueryParameters(queryName))
    Next
    Console.WriteLine()

    Console.WriteLine("RelativePathSegments:")
    For Each segment As String In results.RelativePathSegments
        Console.WriteLine("     {0}", segment)
    Next
    Console.WriteLine()

    Console.WriteLine("RequestUri:")
    Console.WriteLine(results.RequestUri)

    Console.WriteLine("Template:")
    Console.WriteLine(results.Template)

    Console.WriteLine("WildcardPathSegments:")
    For Each segment As String In results.WildcardPathSegments
        Console.WriteLine("     {0}", segment)
    Next
    Console.WriteLine()
End If

注釈

UriTemplateMatch クラスは、Match(Uri, Uri) メソッドを呼び出した結果を表します。 このクラスはスレッド セーフではありません。

コンストラクター

名前 説明
UriTemplateMatch()

UriTemplateMatch クラスの新しいインスタンスを初期化します。

プロパティ

名前 説明
BaseUri

テンプレートの一致のベース URI を取得または設定します。

BoundVariables

テンプレート一致の BoundVariables コレクションを取得します。

Data

UriTemplateMatch インスタンスに関連付けられているオブジェクトを取得または設定します。

QueryParameters

クエリ文字列パラメーターとその値のコレクションを取得します。

RelativePathSegments

相対パス セグメントのコレクションを取得します。

RequestUri

一致する URI を取得または設定します。

Template

このUriTemplate インスタンスに関連付けられているUriTemplateMatch インスタンスを取得または設定します。

WildcardPathSegments

URI テンプレート内のワイルドカードによって照合されるパス セグメントのコレクションを取得します。

メソッド

名前 説明
Equals(Object)

指定したオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Objectの簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

適用対象