RouteValueDictionary RouteValueDictionary RouteValueDictionary RouteValueDictionary Constructors

Definición

Sobrecargas

RouteValueDictionary() RouteValueDictionary() RouteValueDictionary()

Inicializa una nueva instancia de la clase RouteValueDictionary que está vacía.Initializes a new instance of the RouteValueDictionary class that is empty.

RouteValueDictionary(IDictionary<String,Object>) RouteValueDictionary(IDictionary<String,Object>) RouteValueDictionary(IDictionary<String,Object>) RouteValueDictionary(IDictionary<String,Object>)

Inicializa una nueva instancia de la clase RouteValueDictionary y agrega elementos de la colección especificada.Initializes a new instance of the RouteValueDictionary class and adds elements from the specified collection.

RouteValueDictionary(Object) RouteValueDictionary(Object) RouteValueDictionary(Object) RouteValueDictionary(Object)

Inicializa una nueva instancia de la clase RouteValueDictionary y agrega valores que están basados en propiedades del objeto especificado.Initializes a new instance of the RouteValueDictionary class and adds values that are based on properties from the specified object.

RouteValueDictionary() RouteValueDictionary() RouteValueDictionary()

Inicializa una nueva instancia de la clase RouteValueDictionary que está vacía.Initializes a new instance of the RouteValueDictionary class that is empty.

public:
 RouteValueDictionary();
public RouteValueDictionary ();
Public Sub New ()

Comentarios

Puede agregar elementos a un RouteValueDictionary objeto llamando al Add método.You can add elements to a RouteValueDictionary object by calling the Add method.

Consulte también:

RouteValueDictionary(IDictionary<String,Object>) RouteValueDictionary(IDictionary<String,Object>) RouteValueDictionary(IDictionary<String,Object>) RouteValueDictionary(IDictionary<String,Object>)

Inicializa una nueva instancia de la clase RouteValueDictionary y agrega elementos de la colección especificada.Initializes a new instance of the RouteValueDictionary class and adds elements from the specified collection.

public:
 RouteValueDictionary(System::Collections::Generic::IDictionary<System::String ^, System::Object ^> ^ dictionary);
public RouteValueDictionary (System.Collections.Generic.IDictionary<string,object> dictionary);
new System.Web.Routing.RouteValueDictionary : System.Collections.Generic.IDictionary<string, obj> -> System.Web.Routing.RouteValueDictionary
Public Sub New (dictionary As IDictionary(Of String, Object))

Parámetros

dictionary
IDictionary<String,Object>

Colección cuyos elementos se copian en la nueva colección.A collection whose elements are copied to the new collection.

Excepciones

dictionary contiene una o varias claves duplicadas.dictionary contains one or more duplicate keys.

Comentarios

Cada clave de un RouteValueDictionary objeto debe ser única.Every key in a RouteValueDictionary object must be unique. La RouteValueDictionary clase utiliza la comparación ordinal sin distinción entre mayúsculas y minúsculas.The RouteValueDictionary class uses case-insensitive ordinal comparison. Para obtener más información, vea OrdinalIgnoreCase.For more information, see OrdinalIgnoreCase. Una clave no puede nullser.A key cannot be null.

Consulte también:

RouteValueDictionary(Object) RouteValueDictionary(Object) RouteValueDictionary(Object) RouteValueDictionary(Object)

Inicializa una nueva instancia de la clase RouteValueDictionary y agrega valores que están basados en propiedades del objeto especificado.Initializes a new instance of the RouteValueDictionary class and adds values that are based on properties from the specified object.

public:
 RouteValueDictionary(System::Object ^ values);
public RouteValueDictionary (object values);
new System.Web.Routing.RouteValueDictionary : obj -> System.Web.Routing.RouteValueDictionary
Public Sub New (values As Object)

Parámetros

values
Object Object Object Object

Objeto que contiene propiedades que se agregarán como elementos a la nueva colección.An object that contains properties that will be added as elements to the new collection.

Ejemplos

En el ejemplo siguiente se muestra cómo crear Route un objeto y cómo Constraintsestablecer las propiedades DataTokens, y Defaults .The following example shows how to create a Route object and how to set the Constraints, DataTokens, and Defaults properties.

void Application_Start(object sender, EventArgs e) 
{
    RegisterRoutes(RouteTable.Routes);
}

public static void RegisterRoutes(RouteCollection routes)
{
    Route reportRoute = new Route("{locale}/{year}", new ReportRouteHandler());
    reportRoute.Defaults = new RouteValueDictionary { { "locale", "en-US" }, { "year", DateTime.Now.Year.ToString() } };
    reportRoute.Constraints = new RouteValueDictionary { { "locale", "[a-z]{2}-[a-z]{2}" }, { "year", @"\d{4}" } };
    reportRoute.DataTokens = new RouteValueDictionary { { "format", "short" } };
    routes.Add(reportRoute);
}
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
    RegisterRoutes(RouteTable.Routes)
End Sub

Shared Sub RegisterRoutes(ByVal routes As RouteCollection)
    Dim urlPattern As String
    Dim reportRoute As Route
    
    urlPattern = "{locale}/{year}"
    
    reportRoute = New Route(urlPattern, New ReportRouteHandler)
    reportRoute.Defaults = New RouteValueDictionary(New With {.locale = "en-US", .year = DateTime.Now.Year.ToString()})
    reportRoute.Constraints = New RouteValueDictionary(New With {.locale = "[a-z]{2}-[a-z]{2}", .year = "\d{4}"})
    reportRoute.DataTokens = New RouteValueDictionary(New With {.format = "short"})

    routes.Add(reportRoute)
End Sub

Comentarios

Cada clave de un RouteValueDictionary objeto debe ser única según el comparador de igualdad del diccionario.Every key in a RouteValueDictionary object must be unique according to the dictionary's equality comparer. La RouteValueDictionary clase utiliza la comparación ordinal sin distinción entre mayúsculas y minúsculas.The RouteValueDictionary class uses case-insensitive ordinal comparison. Para obtener más información, vea OrdinalIgnoreCase.For more information, see OrdinalIgnoreCase. Una clave no puede nullser.A key cannot be null.

Consulte también:

Se aplica a