UriTemplateMatch.Data 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 o establece el objeto asociado a la UriTemplateMatch instancia de .
public:
property System::Object ^ Data { System::Object ^ get(); void set(System::Object ^ value); };
public object Data { get; set; }
member this.Data : obj with get, set
Public Property Data As Object
Valor de propiedad
Instancia Object de .
Ejemplos
En el código siguiente se muestra cómo acceder a la Data propiedad .
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)
{
Object data = results.Data;
}
Dim prefix As New Uri("http://localhost/")
' Create some templates:
Dim weatherByCity As New UriTemplate("weather/ state}/ city}")
Dim weatherByState As New UriTemplate("weather/ state}")
Dim traffic As New UriTemplate("traffic/*")
Dim wildcard As New UriTemplate("*")
'Create a template table
Dim table As UriTemplateTable = New UriTemplateTable(prefix)
'Add the templates to the template table along with some associated data
table.KeyValuePairs.Add(New KeyValuePair(Of UriTemplate, Object)(weatherByCity, "weatherByCity"))
table.KeyValuePairs.Add(New KeyValuePair(Of UriTemplate, Object)(weatherByState, "weatherByState"))
table.KeyValuePairs.Add(New KeyValuePair(Of UriTemplate, Object)(traffic, "traffic"))
'Match a URI to a template
Dim candidateUri As New Uri("http://localhost/weather/WA/Redmond")
Dim results As UriTemplateMatch = table.MatchSingle(candidateUri)
If (results IsNot Nothing) Then
'Get the data associated with the matching template
Dim data As String = CType(results.Data, String)
Console.WriteLine("Matching data is 0}", Data)
End If
Comentarios
Al agregar un UriTemplate objeto a un UriTemplateTable elemento que asocia datos a la plantilla. Este valor es específico de la aplicación; no hay ninguna semántica determinada asociada a este valor. Cuando Match(Uri) se llama a y se encuentra una coincidencia, los datos asociados a la plantilla coincidente se devuelven en la Data propiedad .