UriTemplateTable.IsReadOnly Propiedad
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Obtiene un valor que especifica si UriTemplateTable es de solo lectura.
public:
property bool IsReadOnly { bool get(); };
public bool IsReadOnly { get; }
member this.IsReadOnly : bool
Public ReadOnly Property IsReadOnly As Boolean
Valor de propiedad
true
si la propiedad UriTemplateTable es de solo lectura; en caso contrario, false
.
Ejemplos
En el siguiente ejemplo se muestra cómo se obtiene acceso a la propiedad IsReadOnly.
Uri baseAddress = new Uri("http://localhost/");
//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(baseAddress, list);
table.MakeReadOnly(true);
if (table.IsReadOnly)
Console.WriteLine("UriTemplateTable is read only");
else
Console.WriteLine("UriTemplateTable is not read only");
Dim baseAddress As New Uri("http://localhost/")
' Create a series of templates
Dim weatherByCity = New UriTemplate("weather/{state}/{city}")
Dim weatherByCountry = New UriTemplate("weather/{country}/{village}")
Dim weatherByState = New UriTemplate("weather/{state}")
Dim traffic = New UriTemplate("traffic/*")
Dim wildcard = 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(baseAddress, list)
table.MakeReadOnly(True)
If (table.IsReadOnly) Then
Console.WriteLine("UriTemplateTable is read only")
Else
Console.WriteLine("UriTemplateTable is not read only")
End If
Comentarios
UriTemplateTable es de solo lectura después de que se llame el método MakeReadOnly(Boolean).