UriTemplateTable.BaseAddress Vlastnost

Definice

Získá nebo nastaví základní adresu 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

Hodnota vlastnosti

Uri

A Uri obsahující základní adresu.

Příklady

Následující příklad ukazuje, jak získat přístup k BaseAddress vlastnosti.

//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)

Poznámky

Vlastnost BaseAddress lze nastavit pouze před voláním MakeReadOnly(Boolean) nebo Match(Uri) MatchSingle(Uri) jinak InvalidOperationException vyvoláním.

Platí pro