Share via


UriTemplateTable.BaseAddress Propriété

Définition

Obtient ou définit l’adresse de base de l’instance UriTemplateTable.

public:
 property Uri ^ BaseAddress { Uri ^ get(); void set(Uri ^ value); };
public Uri BaseAddress { get; set; }
member this.BaseAddress : Uri with get, set
Public Property BaseAddress As Uri

Valeur de propriété

Uri

Uri qui contient l'adresse de base.

Exemples

L'exemple suivant montre comment accéder à la propriété BaseAddress.

//Create a series of templates
UriTemplate weatherByCity = new UriTemplate("weather/{state}/{city}");
UriTemplate weatherByCountry = new UriTemplate("weather/{country}/{village}");
UriTemplate weatherByState = new UriTemplate("weather/{state}");
UriTemplate traffic = new UriTemplate("traffic/*");
UriTemplate wildcard = new UriTemplate("*");

//Add each template to the table with some associated data
List<KeyValuePair<UriTemplate,Object>> list = new List<KeyValuePair<UriTemplate,object>>();
list.Add(new KeyValuePair<UriTemplate, Object>(weatherByCity, "weatherByCity"));
list.Add(new KeyValuePair<UriTemplate, Object>(weatherByCountry, "weatherByCountry"));
list.Add(new KeyValuePair<UriTemplate, Object>(weatherByState, "weatherByState"));
list.Add(new KeyValuePair<UriTemplate, Object>(traffic, "traffic"));

//Create a template table
UriTemplateTable table = new UriTemplateTable(list);
table.BaseAddress = new Uri("http://localhost/");
table.MakeReadOnly(true);
' Create a series of templates
Dim weatherByCity As New UriTemplate("weather/{state}/{city}")
Dim weatherByCountry As New UriTemplate("weather/{country}/{village}")
Dim weatherByState As New UriTemplate("weather/{state}")
Dim traffic As New UriTemplate("traffic/*")
Dim wildcard As New UriTemplate("*")

' Add each template to the table with some associated data
Dim list As New List(Of KeyValuePair(Of UriTemplate, Object))()
list.Add(New KeyValuePair(Of UriTemplate, Object)(weatherByCity, "weatherByCity"))
list.Add(New KeyValuePair(Of UriTemplate, Object)(weatherByCountry, "weatherByCountry"))
list.Add(New KeyValuePair(Of UriTemplate, Object)(weatherByState, "weatherByState"))
list.Add(New KeyValuePair(Of UriTemplate, Object)(traffic, "traffic"))

'Create a template table
Dim table As New UriTemplateTable(list)
table.BaseAddress = New Uri("http://localhost/")
table.MakeReadOnly(True)

Remarques

La propriété BaseAddress ne peut être définie qu'avant d'appeler la méthode MakeReadOnly(Boolean), Match(Uri) ou MatchSingle(Uri) ; sinon, un objet InvalidOperationException est levé.

S’applique à