UriTemplateTable.BaseAddress Właściwość

Definicja

Pobiera lub ustawia adres podstawowy dla UriTemplateTable wystąpienia.

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

Wartość właściwości

Uri

Element Uri zawierający adres podstawowy.

Przykłady

W poniższym przykładzie pokazano, jak uzyskać dostęp BaseAddress do właściwości.

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

Uwagi

Właściwość BaseAddress można ustawić tylko przed wywołaniem MakeReadOnly(Boolean) lub Match(Uri)MatchSingle(Uri) w inny sposób InvalidOperationException jest zgłaszana.

Dotyczy