Unosquare
    Show / Hide Table of Contents

    Class RouteVerbResolverCollection

    Handles a HTTP request by matching it against a list of routes, possibly handling different HTTP methods via different handlers.

    Inheritance
    Object
    RouteResolverCollectionBase<HttpVerb, RouteVerbResolver>
    RouteVerbResolverCollection
    Inherited Members
    RouteResolverCollectionBase<HttpVerb, RouteVerbResolver>.Add(HttpVerb, RouteMatcher, RouteHandlerCallback)
    RouteResolverCollectionBase<HttpVerb, RouteVerbResolver>.Add(HttpVerb, RouteMatcher, SyncRouteHandlerCallback)
    RouteResolverCollectionBase<HttpVerb, RouteVerbResolver>.ResolveAsync(IHttpContext)
    RouteResolverCollectionBase<HttpVerb, RouteVerbResolver>.Lock()
    RouteResolverCollectionBase<HttpVerb, RouteVerbResolver>.OnBeforeLockConfiguration()
    RouteResolverCollectionBase<HttpVerb, RouteVerbResolver>.CreateResolver(RouteMatcher)
    RouteResolverCollectionBase<HttpVerb, RouteVerbResolver>.OnResolverCalled(IHttpContext, RouteVerbResolver, RouteResolutionResult)
    Namespace: EmbedIO.Routing
    Syntax
    public sealed class RouteVerbResolverCollection : RouteResolverCollectionBase<HttpVerb, RouteVerbResolver>

    Methods

    AddFrom(Object)

    Adds handlers, associating them with HTTP method / route pairs by means of RouteAttribute attributes.

    A compatible handler is a static or instance method that takes 2 parameters having the following types, in order:

    1. IHttpContext
    2. RouteMatch

    The return type of a compatible handler may be either langword_csharp_void or .

    A compatible handler, in order to be added to a RouteVerbResolverCollection, must have one or more RouteAttribute attributes. The same handler will be added once for each such attribute, either declared on the handler, or inherited (if the handler is a virtual method).

    This method behaves according to the type of the target parameter:

    • if target is a , all public static methods of the type (either declared on the same type or inherited) that are compatible handlers will be added to the collection;
    • if target is an , all public static methods of each exported type of the assembly (either declared on the same type or inherited) that are compatible handlers will be added to the collection;
    • if target is a referring to a compatible handler, it will be added to the collection;
    • if target is a langword_csharp_delegate whose Method refers to a compatible handler, that method will be added to the collection;
    • if target is none of the above, all public instance methods of its type (either declared on the same type or inherited) that are compatible handlers will be bound to target and added to the collection.

    Declaration
    public int AddFrom(object target)
    Parameters
    Type Name Description
    Object target

    Where to look for compatible handlers. See the Summary section for more information.

    Returns
    Type Description
    Int32

    The number of handlers that were added to the collection.

    Note that methods with multiple RouteAttribute attributes will count as one for each attribute.

    CreateResolver(RouteMatcher)

    Called by Add(TData, RouteMatcher, RouteHandlerCallback) and Add(TData, RouteMatcher, SyncRouteHandlerCallback) to create an instance of TResolver that can resolve the specified route.

    If this method returns null, an is thrown by the calling method.

    Declaration
    protected override RouteVerbResolver CreateResolver(RouteMatcher matcher)
    Parameters
    Type Name Description
    RouteMatcher matcher

    The RouteMatcherto match URL paths against.

    Returns
    Type Description
    RouteVerbResolver

    A newly-constructed instance of TResolver.

    Overrides
    EmbedIO.Routing.RouteResolverCollectionBase<EmbedIO.HttpVerb, EmbedIO.Routing.RouteVerbResolver>.CreateResolver(EmbedIO.Routing.RouteMatcher)

    OnResolverCalled(IHttpContext, RouteVerbResolver, RouteResolutionResult)

    Called by ResolveAsync(IHttpContext) when a resolver's ResolveAsync(IHttpContext) method has been called to resolve a context.

    This callback method may be used e.g. for logging or testing.

    Declaration
    protected override void OnResolverCalled(IHttpContext context, RouteVerbResolver resolver, RouteResolutionResult result)
    Parameters
    Type Name Description
    IHttpContext context

    The context to handle.

    RouteVerbResolver resolver
    RouteResolutionResult result

    The result returned by resolver.ResolveAsync(IHttpContext).

    Overrides
    EmbedIO.Routing.RouteResolverCollectionBase<EmbedIO.HttpVerb, EmbedIO.Routing.RouteVerbResolver>.OnResolverCalled(EmbedIO.IHttpContext, EmbedIO.Routing.RouteVerbResolver, EmbedIO.Routing.RouteResolutionResult)

    See Also

    RouteResolverBase<TData>
    RouteVerbResolver

    Comments

    Back to top Copyright © 2017-2019 Unosquare