Class HttpRouteCollection
A collection of IHttpRoute instances.
public class HttpRouteCollection : ICollection<IHttpRoute>, IEnumerable<IHttpRoute>, IEnumerable, IDisposable
- Inheritance
-
HttpRouteCollection
- Implements
- Inherited Members
Constructors
HttpRouteCollection()
Initializes a new instance of the HttpRouteCollection class.
public HttpRouteCollection()
HttpRouteCollection(string)
Initializes a new instance of the HttpRouteCollection class.
public HttpRouteCollection(string virtualPathRoot)
Parameters
virtualPathRootstringThe virtual path root.
Properties
Count
Gets the number of items in the collection.
public virtual int Count { get; }
Property Value
- int
The number of items in the collection.
IsReadOnly
Gets a value indicating whether the collection is read-only.
public virtual bool IsReadOnly { get; }
Property Value
- bool
true if the collection is read-only; otherwise, false.
this[int]
Gets or sets the element at the specified index.
public virtual IHttpRoute this[int index] { get; }
Parameters
indexintThe index.
Property Value
- IHttpRoute
The IHttpRoute at the specified index.
this[string]
Gets or sets the element with the specified route name.
public virtual IHttpRoute this[string name] { get; }
Parameters
namestringThe route name.
Property Value
- IHttpRoute
The IHttpRoute at the specified index.
VirtualPathRoot
Gets the virtual path root.
public virtual string VirtualPathRoot { get; }
Property Value
- string
The virtual path root.
Methods
Add(string, IHttpRoute)
Adds an IHttpRoute instance to the collection.
public virtual void Add(string name, IHttpRoute route)
Parameters
namestringThe name of the route.
routeIHttpRouteThe IHttpRoute instance to add to the collection.
Clear()
Removes all items from the collection.
public virtual void Clear()
Contains(IHttpRoute)
Determines whether the collection contains a specific IHttpRoute.
public virtual bool Contains(IHttpRoute item)
Parameters
itemIHttpRouteThe object to locate in the collection.
Returns
- bool
true if the IHttpRoute is found in the collection; otherwise, false.
ContainsKey(string)
Determines whether the collection contains an element with the specified key.
public virtual bool ContainsKey(string name)
Parameters
namestringThe key to locate in the collection.
Returns
- bool
true if the collection contains an element with the key; otherwise, false.
CopyTo(KeyValuePair<string, IHttpRoute>[], int)
Copies the IHttpRoute instances of the collection to an array, starting at a particular array index.
public virtual void CopyTo(KeyValuePair<string, IHttpRoute>[] array, int arrayIndex)
Parameters
arrayKeyValuePair<string, IHttpRoute>[]The array that is the destination of the elements copied from the collection.
arrayIndexintThe zero-based index in
arrayat which copying begins.
CopyTo(IHttpRoute[], int)
Copies the route names and IHttpRoute instances of the collection to an array, starting at a particular array index.
public virtual void CopyTo(IHttpRoute[] array, int arrayIndex)
Parameters
arrayIHttpRoute[]The array that is the destination of the elements copied from the collection.
arrayIndexintThe zero-based index in
arrayat which copying begins.
CreateRoute(string, IDictionary<string, object>, IDictionary<string, object>, IDictionary<string, object>)
Creates an IHttpRoute instance.
public IHttpRoute CreateRoute(string routeTemplate, IDictionary<string, object> defaults, IDictionary<string, object> constraints, IDictionary<string, object> dataTokens)
Parameters
routeTemplatestringThe route template.
defaultsIDictionary<string, object>An object that contains the default route parameters.
constraintsIDictionary<string, object>An object that contains the route constraints.
dataTokensIDictionary<string, object>The route data tokens.
Returns
- IHttpRoute
The new IHttpRoute instance.
CreateRoute(string, IDictionary<string, object>, IDictionary<string, object>, IDictionary<string, object>, HttpMessageHandler)
Creates an IHttpRoute instance.
public virtual IHttpRoute CreateRoute(string routeTemplate, IDictionary<string, object> defaults, IDictionary<string, object> constraints, IDictionary<string, object> dataTokens, HttpMessageHandler handler)
Parameters
routeTemplatestringThe route template.
defaultsIDictionary<string, object>An object that contains the default route parameters.
constraintsIDictionary<string, object>An object that contains the route constraints.
dataTokensIDictionary<string, object>The route data tokens.
handlerHttpMessageHandlerThe message handler for the route.
Returns
- IHttpRoute
The new IHttpRoute instance.
CreateRoute(string, object, object)
Creates an IHttpRoute instance.
public IHttpRoute CreateRoute(string routeTemplate, object defaults, object constraints)
Parameters
routeTemplatestringThe route template.
defaultsobjectAn object that contains the default route parameters.
constraintsobjectAn object that contains the route constraints.
Returns
- IHttpRoute
The new IHttpRoute instance.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Dispose(bool)
Releases the unmanaged resources that are used by the object and, optionally, releases the managed resources.
protected virtual void Dispose(bool disposing)
Parameters
disposingbooltrue to release both managed and unmanaged resources; false to release only unmanaged resources.
GetEnumerator()
Returns an enumerator that iterates through the collection.
public virtual IEnumerator<IHttpRoute> GetEnumerator()
Returns
- IEnumerator<IHttpRoute>
An IEnumerator<T> that can be used to iterate through the collection.
GetRouteData(HttpRequestMessage)
Gets the route data for a specified HTTP request.
public virtual IHttpRouteData GetRouteData(HttpRequestMessage request)
Parameters
requestHttpRequestMessageThe HTTP request.
Returns
- IHttpRouteData
AnIHttpRouteData instance that represents the route data.
GetVirtualPath(HttpRequestMessage, string, IDictionary<string, object>)
Gets a virtual path.
public virtual IHttpVirtualPathData GetVirtualPath(HttpRequestMessage request, string name, IDictionary<string, object> values)
Parameters
requestHttpRequestMessageThe HTTP request.
namestringThe route name.
valuesIDictionary<string, object>The route values.
Returns
- IHttpVirtualPathData
An IHttpVirtualPathData instance that represents the virtual path.
Insert(int, string, IHttpRoute)
Inserts an IHttpRoute instance into the collection.
public virtual void Insert(int index, string name, IHttpRoute value)
Parameters
indexintThe zero-based index at which
valueshould be inserted.namestringThe route name.
valueIHttpRouteThe IHttpRoute to insert. The value cannot be null.
OnGetEnumerator()
Called internally to get the enumerator for the collection.
protected virtual IEnumerator OnGetEnumerator()
Returns
- IEnumerator
An IEnumerator that can be used to iterate through the collection.
Remove(string)
Removes an IHttpRoute instance from the collection.
public virtual bool Remove(string name)
Parameters
namestringThe name of the route to remove.
Returns
- bool
true if the element is successfully removed; otherwise, false. This method also returns false if
namewas not found in the collection.
TryGetValue(string, out IHttpRoute)
Gets the IHttpRoute with the specified route name.
public virtual bool TryGetValue(string name, out IHttpRoute route)
Parameters
namestringThe route name.
routeIHttpRouteWhen this method returns, contains the IHttpRoute instance, if the route name is found; otherwise, null. This parameter is passed uninitialized.
Returns
- bool
true if the collection contains an element with the specified name; otherwise, false.
ValidateConstraint(string, string, object)
Validates that a constraint is valid for an IHttpRoute created by a call to the CreateRoute(string, IDictionary<string, object>, IDictionary<string, object>, IDictionary<string, object>, HttpMessageHandler) method.
protected virtual void ValidateConstraint(string routeTemplate, string name, object constraint)