Afficher en anglais

Partage via


UriTemplateTable Constructeurs

Définition

Initialise une nouvelle instance de la classe UriTemplateTable.

Surcharges

UriTemplateTable()

Initialise une nouvelle instance de la classe UriTemplateTable.

UriTemplateTable(IEnumerable<KeyValuePair<UriTemplate,Object>>)

Initialise une nouvelle instance de la classe UriTemplateTable avec la collection spécifiée de paires clé/valeur.

UriTemplateTable(Uri)

Initialise une nouvelle instance de la classe UriTemplateTable avec l'adresse de base spécifiée.

UriTemplateTable(Uri, IEnumerable<KeyValuePair<UriTemplate,Object>>)

Initialise une nouvelle instance de la classe UriTemplateTable avec l’adresse de base spécifiée et la collection de paires clé/valeur.

UriTemplateTable()

Initialise une nouvelle instance de la classe UriTemplateTable.

C#
public UriTemplateTable ();

Exemples

L'exemple suivant montre comment instancier la classe UriTemplateTable.

C#
Uri prefix = 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("*");

//Create a template table
UriTemplateTable table = new UriTemplateTable(prefix);
//Add each template to the table with some associated data
table.KeyValuePairs.Add(new KeyValuePair<UriTemplate, Object>(weatherByCity, "weatherByCity"));
table.KeyValuePairs.Add(new KeyValuePair<UriTemplate, Object>(weatherByCountry, "weatherByCountry"));
table.KeyValuePairs.Add(new KeyValuePair<UriTemplate, Object>(weatherByState, "weatherByState"));
table.KeyValuePairs.Add(new KeyValuePair<UriTemplate, Object>(traffic, "traffic"));

table.MakeReadOnly(true);

S’applique à

.NET Framework 4.8 et autres versions
Produit Versions
.NET Framework 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8

UriTemplateTable(IEnumerable<KeyValuePair<UriTemplate,Object>>)

Initialise une nouvelle instance de la classe UriTemplateTable avec la collection spécifiée de paires clé/valeur.

C#
public UriTemplateTable (System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<UriTemplate,object>> keyValuePairs);

Paramètres

keyValuePairs
IEnumerable<KeyValuePair<UriTemplate,Object>>

Collection de paires clé/valeur qui se composent de modèles URI et de données associées.

Exemples

L'exemple suivant montre comment instancier la classe UriTemplateTable.

C#
//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);

S’applique à

.NET Framework 4.8 et autres versions
Produit Versions
.NET Framework 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8

UriTemplateTable(Uri)

Initialise une nouvelle instance de la classe UriTemplateTable avec l'adresse de base spécifiée.

C#
public UriTemplateTable (Uri baseAddress);

Paramètres

baseAddress
Uri

Instance Uri qui contient l'adresse de base.

Exemples

L'exemple suivant montre comment appeler ce constructeur.

C#
Uri prefix = 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("*");

//Create a template table
UriTemplateTable table = new UriTemplateTable(prefix);
//Add each template to the table with some associated data
table.KeyValuePairs.Add(new KeyValuePair<UriTemplate, Object>(weatherByCity, "weatherByCity"));
table.KeyValuePairs.Add(new KeyValuePair<UriTemplate, Object>(weatherByCountry, "weatherByCountry"));
table.KeyValuePairs.Add(new KeyValuePair<UriTemplate, Object>(weatherByState, "weatherByState"));
table.KeyValuePairs.Add(new KeyValuePair<UriTemplate, Object>(traffic, "traffic"));

table.MakeReadOnly(true);

S’applique à

.NET Framework 4.8 et autres versions
Produit Versions
.NET Framework 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8

UriTemplateTable(Uri, IEnumerable<KeyValuePair<UriTemplate,Object>>)

Initialise une nouvelle instance de la classe UriTemplateTable avec l’adresse de base spécifiée et la collection de paires clé/valeur.

C#
public UriTemplateTable (Uri baseAddress, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<UriTemplate,object>> keyValuePairs);

Paramètres

baseAddress
Uri

Instance Uri qui contient l'adresse de base.

keyValuePairs
IEnumerable<KeyValuePair<UriTemplate,Object>>

Collection de paires clé/valeur qui se composent de modèles URI et de données associées.

Exemples

L'exemple suivant montre comment appeler ce constructeur.

C#
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);

S’applique à

.NET Framework 4.8 et autres versions
Produit Versions
.NET Framework 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8