Unosquare
    Show / Hide Table of Contents

    Class RouteResolverCollectionBase<TData, TResolver>

    Implements the logic for resolving a context and a URL path against a list of routes, possibly handling different HTTP methods via different handlers.

    Inheritance
    Object
    RouteResolverCollectionBase<TData, TResolver>
    RouteVerbResolverCollection
    Namespace: EmbedIO.Routing
    Syntax
    public abstract class RouteResolverCollectionBase<TData, TResolver> : ConfiguredObject where TResolver : RouteResolverBase<TData>
    Type Parameters
    Name Description
    TData

    The type of the data used to select a suitable handler for a context.

    TResolver

    The type of the route resolver.

    Methods

    Add(TData, RouteMatcher, RouteHandlerCallback)

    Associates some data and a route to a handler.

    Declaration
    public void Add(TData data, RouteMatcher matcher, RouteHandlerCallback handler)
    Parameters
    Type Name Description
    TData data

    Data used to determine which contexts are suitable to be handled by handler.

    RouteMatcher matcher

    The RouteMatcherto match URL paths against.

    RouteHandlerCallback handler

    A callback used to handle matching contexts.

    See Also
    ResolveAsync(IHttpContext)
    Add(TData, RouteMatcher, SyncRouteHandlerCallback)
    Add(TData, RouteHandlerCallback)

    Add(TData, RouteMatcher, SyncRouteHandlerCallback)

    Associates some data and a route to a synchronous handler.

    Declaration
    public void Add(TData data, RouteMatcher matcher, SyncRouteHandlerCallback handler)
    Parameters
    Type Name Description
    TData data

    Data used to determine which contexts are suitable to be handled by handler.

    RouteMatcher matcher

    The RouteMatcherto match URL paths against.

    SyncRouteHandlerCallback handler

    A callback used to handle matching contexts.

    See Also
    ResolveAsync(IHttpContext)
    Add(TData, RouteMatcher, RouteHandlerCallback)
    Add(TData, SyncRouteHandlerCallback)

    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 abstract TResolver CreateResolver(RouteMatcher matcher)
    Parameters
    Type Name Description
    RouteMatcher matcher

    The RouteMatcherto match URL paths against.

    Returns
    Type Description
    TResolver

    A newly-constructed instance of TResolver.

    Lock()

    Locks this collection, preventing further additions.

    Declaration
    public void Lock()

    OnBeforeLockConfiguration()

    Declaration
    protected override void OnBeforeLockConfiguration()

    OnResolverCalled(IHttpContext, TResolver, 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 virtual void OnResolverCalled(IHttpContext context, TResolver resolver, RouteResolutionResult result)
    Parameters
    Type Name Description
    IHttpContext context

    The context to handle.

    TResolver resolver

    The resolver just called.

    RouteResolutionResult result

    The result returned by resolver.ResolveAsync(IHttpContext).

    ResolveAsync(IHttpContext)

    Asynchronously matches a URL path against Route; if the match is successful, tries to handle the specified context using handlers selected according to data extracted from the context.

    Registered resolvers are tried in the same order they were added by calling .

    Declaration
    public Task<RouteResolutionResult> ResolveAsync(IHttpContext context)
    Parameters
    Type Name Description
    IHttpContext context

    The context to handle.

    Returns
    Type Description
    Task<RouteResolutionResult>

    A , representing the ongoing operation, that will return a result in the form of one of the RouteResolutionResult constants.

    See Also
    ResolveAsync(IHttpContext)

    Comments

    Back to top Copyright © 2017-2019 Unosquare