当前位置: 首页>>代码示例>>C#>>正文


C# IRouteResolver类代码示例

本文整理汇总了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);
        }
开发者ID:sloncho,项目名称:Nancy,代码行数:30,代码来源:DefaultRequestDispatcherFixture.cs

示例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);
 }
开发者ID:meadiagenic,项目名称:Nancy,代码行数:7,代码来源:NancyEngineFixture.cs

示例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);
 }
开发者ID:dineshkummarc,项目名称:Nancy,代码行数:7,代码来源:NancyEngineFixture.cs

示例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
                };
        }
开发者ID:rhwy,项目名称:Nancy,代码行数:33,代码来源:NancyEngineFixture.cs

示例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;
        }
开发者ID:nwendel,项目名称:brickpile,代码行数:44,代码来源:DefaultRoute.cs

示例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;
        }
开发者ID:GraemeF,项目名称:Nancy,代码行数:34,代码来源:NancyEngine.cs

示例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);
        }
开发者ID:kppullin,项目名称:Nancy,代码行数:25,代码来源:DefaultRequestDispatcherFixture.cs

示例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);
        }
开发者ID:leoduran,项目名称:Nancy,代码行数:35,代码来源:DefaultRequestDispatcherFixture.cs

示例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
                };
        }
开发者ID:randacc,项目名称:Nancy,代码行数:35,代码来源:NancyEngineFixture.cs

示例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;
        }
开发者ID:marcuslindblom,项目名称:aspnet5,代码行数:27,代码来源:DefaultRouter.cs

示例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);
 }
开发者ID:ryansroberts,项目名称:Nancy,代码行数:8,代码来源:NancyEngineFixture.cs

示例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>());
        }
开发者ID:avlasova,项目名称:Nancy,代码行数:8,代码来源:NancyEngineFixture.cs

示例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;
        }
开发者ID:tt,项目名称:Nancy,代码行数:13,代码来源:NancyEngine.cs

示例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;
 }
开发者ID:ReactiveMarkets,项目名称:Styx,代码行数:9,代码来源:DefaultHandshakeNegotiator.cs

示例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;
 }
开发者ID:rdterner,项目名称:Nancy,代码行数:18,代码来源:DefaultRequestDispatcher.cs


注:本文中的IRouteResolver类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。