本文整理汇总了C#中IRouteResolver类的典型用法代码示例。如果您正苦于以下问题:C# IRouteResolver类的具体用法?C# IRouteResolver怎么用?C# IRouteResolver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IRouteResolver类属于命名空间,在下文中一共展示了IRouteResolver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DefaultRequestDispatcherFixture
public DefaultRequestDispatcherFixture()
{
this.responseProcessors = new List<IResponseProcessor>();
this.routeResolver = A.Fake<IRouteResolver>();
this.routeInvoker = A.Fake<IRouteInvoker>();
this.negotiator = A.Fake<IResponseNegotiator>();
A.CallTo(() => this.routeInvoker.Invoke(A<Route>._, A<CancellationToken>._, A<DynamicDictionary>._, A<NancyContext>._))
.ReturnsLazily(async arg =>
{
var routeResult = ((Route)arg.Arguments[0]).Invoke((DynamicDictionary)arg.Arguments[2], new CancellationToken()).ConfigureAwait(false);
var x = await routeResult;
return (Response)x;
});
this.requestDispatcher =
new DefaultRequestDispatcher(this.routeResolver, this.responseProcessors, this.routeInvoker, this.negotiator);
var resolvedRoute = new ResolveResult
{
Route = new FakeRoute(),
Parameters = DynamicDictionary.Empty,
Before = null,
After = null,
OnError = null
};
A.CallTo(() => this.routeResolver.Resolve(A<NancyContext>._)).Returns(resolvedRoute);
}
示例2: NancyEngineFixture
public NancyEngineFixture()
{
this.application = A.Fake<INancyApplication>();
this.modules = NancyBootstrapper.BootstrapApplication().ModuleMetas;
this.resolver = A.Fake<IRouteResolver>();
this.engine = new NancyEngine(this.resolver, this.application);
}
示例3: NancyEngineFixture
public NancyEngineFixture()
{
this.modules = new[] { new FakeNancyModuleWithBasePath() };
this.locator = A.Fake<INancyModuleLocator>();
this.resolver = A.Fake<IRouteResolver>();
this.engine = new NancyEngine(this.locator, this.resolver);
}
示例4: NancyEngineFixture
public NancyEngineFixture()
{
this.resolver = A.Fake<IRouteResolver>();
this.response = new Response();
this.route = new FakeRoute(response);
this.context = new NancyContext();
this.errorHandler = A.Fake<IErrorHandler>();
this.requestDispatcher = A.Fake<IRequestDispatcher>();
A.CallTo(() => this.requestDispatcher.Dispatch(A<NancyContext>._)).Invokes(x => this.context.Response = new Response());
A.CallTo(() => errorHandler.HandlesStatusCode(A<HttpStatusCode>.Ignored, A<NancyContext>.Ignored)).Returns(false);
contextFactory = A.Fake<INancyContextFactory>();
A.CallTo(() => contextFactory.Create()).Returns(context);
A.CallTo(() => resolver.Resolve(A<NancyContext>.Ignored)).Returns(new ResolveResult(route, DynamicDictionary.Empty, null, null, null));
var applicationPipelines = new Pipelines();
this.routeInvoker = A.Fake<IRouteInvoker>();
A.CallTo(() => this.routeInvoker.Invoke(A<Route>._, A<DynamicDictionary>._, A<NancyContext>._)).ReturnsLazily(arg =>
{
return (Response)((Route)arg.Arguments[0]).Action.Invoke((DynamicDictionary)arg.Arguments[1]);
});
this.engine =
new NancyEngine(this.requestDispatcher, contextFactory, new[] { this.errorHandler }, A.Fake<IRequestTracing>())
{
RequestPipelinesFactory = ctx => applicationPipelines
};
}
示例5: DefaultRoute
/// <summary>
/// Initializes a new instance of the <see cref="DefaultRoute" /> class.
/// </summary>
/// <param name="virtualPathResolver">The virtual path resolver.</param>
/// <param name="routeResolver">The route resolver.</param>
/// <param name="documentStore">The document store.</param>
/// <param name="controllerMapper">The controller mapper.</param>
/// <exception cref="System.ArgumentNullException">
/// virtualPathResolver
/// or
/// routeResolver
/// or
/// documentStore
/// or
/// controllerMapper
/// </exception>
public DefaultRoute(IVirtualPathResolver virtualPathResolver, IRouteResolver routeResolver,
IDocumentStore documentStore, IControllerMapper controllerMapper)
{
if (virtualPathResolver == null)
{
throw new ArgumentNullException("virtualPathResolver");
}
if (routeResolver == null)
{
throw new ArgumentNullException("routeResolver");
}
if (documentStore == null)
{
throw new ArgumentNullException("documentStore");
}
if (controllerMapper == null)
{
throw new ArgumentNullException("controllerMapper");
}
this.VirtualPathResolver = virtualPathResolver;
this.RouteResolver = routeResolver;
this.DocumentStore = documentStore;
this.ControllerMapper = controllerMapper;
}
示例6: NancyEngine
/// <summary>
/// Initializes a new instance of the <see cref="NancyEngine"/> class.
/// </summary>
/// <param name="resolver">An <see cref="IRouteResolver"/> instance that will be used to resolve a route, from the modules, that matches the incoming <see cref="Request"/>.</param>
/// <param name="routeCache">Cache of all available routes</param>
/// <param name="contextFactory">A factory for creating contexts</param>
/// <param name="errorHandlers">Error handlers</param>
public NancyEngine(IRouteResolver resolver, IRouteCache routeCache, INancyContextFactory contextFactory, IEnumerable<IErrorHandler> errorHandlers)
{
if (resolver == null)
{
throw new ArgumentNullException("resolver", "The resolver parameter cannot be null.");
}
if (routeCache == null)
{
throw new ArgumentNullException("routeCache", "The routeCache parameter cannot be null.");
}
if (contextFactory == null)
{
throw new ArgumentNullException("contextFactory");
}
if (errorHandlers == null)
{
throw new ArgumentNullException("errorHandlers");
}
this.resolver = resolver;
this.routeCache = routeCache;
this.contextFactory = contextFactory;
this.errorHandlers = errorHandlers;
}
示例7: DefaultRequestDispatcherFixture
public DefaultRequestDispatcherFixture()
{
this.responseProcessors = new List<IResponseProcessor>();
this.routeResolver = A.Fake<IRouteResolver>();
this.routeInvoker = A.Fake<IRouteInvoker>();
A.CallTo(() => this.routeInvoker.Invoke(A<Route>._, A<DynamicDictionary>._, A<NancyContext>._)).ReturnsLazily(arg =>
{
return (Response)((Route)arg.Arguments[0]).Action.Invoke(arg.Arguments[1]);
});
this.requestDispatcher =
new DefaultRequestDispatcher(this.routeResolver, this.responseProcessors, this.routeInvoker);
var resolvedRoute = new ResolveResult
{
Route = new FakeRoute(),
Parameters = DynamicDictionary.Empty,
Before = null,
After = null,
OnError = null
};
A.CallTo(() => this.routeResolver.Resolve(A<NancyContext>._)).Returns(resolvedRoute);
}
示例8: DefaultRequestDispatcherFixture
public DefaultRequestDispatcherFixture()
{
this.responseProcessors = new List<IResponseProcessor>();
this.routeResolver = A.Fake<IRouteResolver>();
this.routeInvoker = A.Fake<IRouteInvoker>();
A.CallTo(() => this.routeInvoker.Invoke(A<Route>._, A<CancellationToken>._, A<DynamicDictionary>._, A<NancyContext>._)).ReturnsLazily(arg =>
{
var tcs = new TaskCompletionSource<Response>();
var actionResult =
((Route)arg.Arguments[0]).Action.Invoke(arg.Arguments[2], new CancellationToken());
var result =
actionResult.Result;
tcs.SetResult(result);
return tcs.Task;
});
this.requestDispatcher =
new DefaultRequestDispatcher(this.routeResolver, this.responseProcessors, this.routeInvoker);
var resolvedRoute = new ResolveResult
{
Route = new FakeRoute(),
Parameters = DynamicDictionary.Empty,
Before = null,
After = null,
OnError = null
};
A.CallTo(() => this.routeResolver.Resolve(A<NancyContext>._)).Returns(resolvedRoute);
}
示例9: NancyEngineFixture
public NancyEngineFixture()
{
this.resolver = A.Fake<IRouteResolver>();
this.response = new Response();
this.route = new FakeRoute(response);
this.context = new NancyContext();
this.statusCodeHandler = A.Fake<IStatusCodeHandler>();
this.requestDispatcher = A.Fake<IRequestDispatcher>();
this.diagnosticsConfiguration = new DiagnosticsConfiguration();
A.CallTo(() => this.requestDispatcher.Dispatch(A<NancyContext>._, A<CancellationToken>._)).Invokes((x) => this.context.Response = new Response());
A.CallTo(() => this.statusCodeHandler.HandlesStatusCode(A<HttpStatusCode>.Ignored, A<NancyContext>.Ignored)).Returns(false);
contextFactory = A.Fake<INancyContextFactory>();
A.CallTo(() => contextFactory.Create(A<Request>._)).Returns(context);
var resolveResult = new ResolveResult { Route = route, Parameters = DynamicDictionary.Empty, Before = null, After = null, OnError = null };
A.CallTo(() => resolver.Resolve(A<NancyContext>.Ignored)).Returns(resolveResult);
var applicationPipelines = new Pipelines();
this.routeInvoker = A.Fake<IRouteInvoker>();
A.CallTo(() => this.routeInvoker.Invoke(A<Route>._, A<CancellationToken>._, A<DynamicDictionary>._, A<NancyContext>._)).ReturnsLazily(arg =>
{
return ((Route)arg.Arguments[0]).Action.Invoke((DynamicDictionary)arg.Arguments[1], A<CancellationToken>._).Result;
});
this.engine =
new NancyEngine(this.requestDispatcher, this.contextFactory, new[] { this.statusCodeHandler }, A.Fake<IRequestTracing>(), this.diagnosticsConfiguration, new DisabledStaticContentProvider())
{
RequestPipelinesFactory = ctx => applicationPipelines
};
}
示例10: DefaultRouter
public DefaultRouter(IRouter defaultHandler, IRouteResolver routeResolver, IVirtualPathResolver virtualPathResolver, RequestCulture defaultRequestCulture)
{
if (defaultHandler == null)
{
throw new ArgumentNullException(nameof(defaultHandler));
}
if (routeResolver == null)
{
throw new ArgumentNullException(nameof(routeResolver));
}
if (virtualPathResolver == null)
{
throw new ArgumentNullException(nameof(virtualPathResolver));
}
if (defaultRequestCulture == null)
{
throw new ArgumentNullException(nameof(defaultRequestCulture));
}
_defaultHandler = defaultHandler;
_routeResolver = routeResolver;
_virtualPathResolver = virtualPathResolver;
_defaultRequestCulture = defaultRequestCulture;
}
示例11: NancyEngineFixture
public NancyEngineFixture()
{
this.modules = new NancyApplication(new DefaultModuleActivator()).GetModules();
this.locator = A.Fake<INancyModuleLocator>();
this.resolver = A.Fake<IRouteResolver>();
this.application = A.Fake<INancyApplication>();
this.engine = new NancyEngine(this.locator, this.resolver, this.application);
}
示例12: NancyEngineFixture
public NancyEngineFixture()
{
this.resolver = A.Fake<IRouteResolver>();
this.route = new FakeRoute();
A.CallTo(() => resolver.Resolve(A<Request>.Ignored, A<IRouteCache>.Ignored.Argument)).Returns(route);
this.engine = new NancyEngine(resolver, A.Fake<IRouteCache>());
}
示例13: NancyEngine
/// <summary>
/// Initializes a new instance of the <see cref="NancyEngine"/> class.
/// </summary>
/// <param name="resolver">An <see cref="IRouteResolver"/> instance that will be used to resolve a route, from the modules, that matches the incoming <see cref="Request"/>.</param>
public NancyEngine(IRouteResolver resolver)
{
if (resolver == null)
{
throw new ArgumentNullException("resolver", "The resolver parameter cannot be null.");
}
this.resolver = resolver;
}
示例14: DefaultHandshakeNegotiator
public DefaultHandshakeNegotiator(IHostConfiguration hostConfiguration, IProtocolSelector protocolSelector, IQueryParametersBuilder queryParametersBuilder, IRouteParametersBuilder routeParametersBuilder, IRouteResolver routeResolver, ISubProtocolNegotiator subProtocolNegotiator)
{
_hostConfiguration = hostConfiguration;
_protocolSelector = protocolSelector;
_queryParametersBuilder = queryParametersBuilder;
_routeParametersBuilder = routeParametersBuilder;
_routeResolver = routeResolver;
_subProtocolNegotiator = subProtocolNegotiator;
}
示例15: DefaultRequestDispatcher
/// <summary>
/// Initializes a new instance of the <see cref="DefaultRequestDispatcher"/> class, with
/// the provided <paramref name="routeResolver"/>, <paramref name="responseProcessors"/> and <paramref name="routeInvoker"/>.
/// </summary>
/// <param name="routeResolver"></param>
/// <param name="responseProcessors"></param>
/// <param name="routeInvoker"></param>
/// <param name="negotiator"></param>
public DefaultRequestDispatcher(IRouteResolver routeResolver,
IEnumerable<IResponseProcessor> responseProcessors,
IRouteInvoker routeInvoker,
IResponseNegotiator negotiator)
{
this.routeResolver = routeResolver;
this.responseProcessors = responseProcessors;
this.routeInvoker = routeInvoker;
this.negotiator = negotiator;
}