コード例 #1
1
        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
0
        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);
        }
コード例 #3
0
ファイル: DefaultRoute.cs プロジェクト: nwendel/brickpile
        /// <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;
        }
コード例 #4
0
ファイル: NancyEngineFixture.cs プロジェクト: rhwy/Nancy
        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
0
        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;
        }
コード例 #6
0
 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);
 }
コード例 #7
0
        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
0
ファイル: NancyEngineFixture.cs プロジェクト: randacc/Nancy
        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
                };
        }
コード例 #9
0
 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);
 }
コード例 #10
0
ファイル: NancyEngine.cs プロジェクト: GraemeF/Nancy
        /// <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;
        }
コード例 #11
0
 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
0
ファイル: NancyEngineFixture.cs プロジェクト: avlasova/Nancy
        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
0
ファイル: NancyEngine.cs プロジェクト: tt/Nancy
        /// <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
0
 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
0
 /// <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;
 }
コード例 #16
0
        public RequestModel(NancyContext context, IRootPathProvider rootPathProvider, IRouteResolver routeResolver)
        {
            this.context = context;
            this.rootPathProvider = rootPathProvider;
            this.routeResolution = routeResolver.Resolve(context);

            Cookies = this.context.Request.Headers.Cookie.Select(x => new CookieModel(x)).ToArray();
            QueryString = ((DynamicDictionary)this.context.Request.Query).Serialize();
            Parameters = this.routeResolution.Parameters.Serialize();
        }
コード例 #17
0
ファイル: Navigator.cs プロジェクト: p69/magellan-framework
        /// <summary>
        /// Initializes a new instance of the <see cref="Navigator"/> class.
        /// </summary>
        /// <param name="parent">The parent.</param>
        /// <param name="scheme">The URI scheme.</param>
        /// <param name="routes">The routes.</param>
        /// <param name="navigationService">The navigation service.</param>
        public Navigator(INavigatorFactory parent, string scheme, IRouteResolver routes, Func<INavigationService> navigationService)
            : base(navigationService)
        {
            Guard.ArgumentNotNull(parent, "root");
            Guard.ArgumentNotNull(routes, "routes");
            Guard.ArgumentNotNull(navigationService, "navigationService");

            _parent = parent;
            _scheme = scheme;
            _routes = routes;
        }
コード例 #18
0
ファイル: Navigator.cs プロジェクト: p69/magellan-framework
    	/// <summary>
    	/// Initializes a new instance of the <see cref="Navigator"/> class.
    	/// </summary>
    	/// <param name="factory">The factory that created this navigator.</param>
    	/// <param name="parent">The parent navigator (can be null).</param>
    	/// <param name="scheme">The URI scheme.</param>
    	/// <param name="routes">The routes.</param>
    	/// <param name="navigationService">The navigation service.</param>
    	public Navigator(INavigatorFactory factory, INavigator parent, string scheme, IRouteResolver routes, Func<INavigationService> navigationService)
            : base(navigationService)
        {
            Guard.ArgumentNotNull(factory, "root");
            Guard.ArgumentNotNull(routes, "routes");
            Guard.ArgumentNotNull(navigationService, "navigationService");

            this.factory = factory;
			this.parent = parent;
            this.scheme = scheme;
            this.routes = routes;
        }
コード例 #19
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="nancyBootstrapper"></param>
 /// <param name="routeResolver"></param>
 /// <param name="pipeline"></param>
 /// <param name="cacheKeyGenerator"></param>
 /// <param name="cacheStore"></param>
 public static void Enable(INancyBootstrapper nancyBootstrapper, IRouteResolver routeResolver, IPipelines pipeline, ICacheKeyGenerator cacheKeyGenerator, ICacheStore cacheStore)
 {
     if (_enabled)
         return;
     _enabled = true;
     _cacheKeyGenerator = cacheKeyGenerator;
     _cacheStore = cacheStore;
     _nancyBootstrapper = nancyBootstrapper;
     _routeResolver = routeResolver;
     pipeline.BeforeRequest.AddItemToStartOfPipeline(CheckCache);
     pipeline.AfterRequest.AddItemToEndOfPipeline(SetCache);
 }
コード例 #20
0
ファイル: LightningCache.cs プロジェクト: jchindev/testing1
 /// <summary>
 /// 
 /// </summary>
 /// <param name="nancyBootstrapper"></param>
 /// <param name="routeResolver"></param>
 /// <param name="pipeline"></param>
 /// <param name="varyParams"></param>
 /// <param name="cacheStore"></param>
 public static void Enable(INancyBootstrapper nancyBootstrapper, IRouteResolver routeResolver, IPipelines pipeline, IEnumerable<string> varyParams, ICacheStore cacheStore)
 {
     if (_enabled)
         return;
     _enabled = true;
     _varyParams = varyParams.Select(key => key.ToLower().Trim()).ToArray();
     _cacheStore = cacheStore;
     _nancyBootstrapper = nancyBootstrapper;
     _routeResolver = routeResolver;
     pipeline.BeforeRequest.AddItemToStartOfPipeline(CheckCache);
     pipeline.AfterRequest.AddItemToEndOfPipeline(SetCache);
 }
コード例 #21
0
ファイル: ResourceResolver.cs プロジェクト: BeeWarloc/Pomona
 public ResourceResolver(ITypeMapper typeMapper, NancyContext context, IRouteResolver routeResolver)
 {
     if (typeMapper == null)
         throw new ArgumentNullException("typeMapper");
     if (context == null)
         throw new ArgumentNullException("context");
     if (routeResolver == null)
         throw new ArgumentNullException("routeResolver");
     //if (routeResolver == null) throw new ArgumentNullException("routeResolver");
     this.typeMapper = typeMapper;
     this.context = context;
     this.routeResolver = routeResolver;
 }
コード例 #22
0
ファイル: NancyEngineFixture.cs プロジェクト: ToJans/Nancy
        public NancyEngineFixture()
        {
            this.resolver = A.Fake<IRouteResolver>();
            this.response = new Response();
            this.route = new FakeRoute(response);
            this.context = new NancyContext();

            contextFactory = A.Fake<INancyContextFactory>();
            A.CallTo(() => contextFactory.Create()).Returns(context);

            A.CallTo(() => resolver.Resolve(A<NancyContext>.Ignored, A<IRouteCache>.Ignored.Argument)).Returns(new ResolveResult(route, DynamicDictionary.Empty, null, null));

            this.engine = new NancyEngine(resolver, A.Fake<IRouteCache>(), contextFactory);
        }
コード例 #23
0
ファイル: NancyEngine.cs プロジェクト: meadiagenic/Nancy
        /// <summary>
        /// Initializes a new instance of the <see cref="NancyEngine"/> class.
        /// </summary>
        /// <param name="locator">An <see cref="INancyModuleLocator"/> instance, that will be used to locate <see cref="NancyModule"/> instances</param>
        /// <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, INancyApplication application)
        {
            if (resolver == null)
            {
                throw new ArgumentNullException("resolver", "The resolver parameter cannot be null.");
            }

            if (application == null)
            {
                throw new ArgumentNullException("application", "The application parameter cannot be null.");
            }

            this.resolver = resolver;
            this.application = application;
        }
コード例 #24
0
ファイル: NancyEngine.cs プロジェクト: emmanuelmorales/Nancy
        /// <summary>
        /// Initializes a new instance of the <see cref="NancyEngine"/> class.
        /// </summary>
        /// <param name="locator">An <see cref="INancyModuleLocator"/> instance, that will be used to locate <see cref="NancyModule"/> instances</param>
        /// <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(INancyModuleLocator locator, IRouteResolver resolver)
        {
            if (locator == null)
            {
                throw new ArgumentNullException("locator", "The locator parameter cannot be null.");
            }

            if (resolver == null)
            {
                throw new ArgumentNullException("resolver", "The resolver parameter cannot be null.");
            }

            this.locator = locator;
            this.resolver = resolver;
        }
コード例 #25
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NavigatorFactory"/> class.
        /// </summary>
        /// <param name="uriScheme">The URI scheme that will prefix handled URI's.</param>
        /// <param name="routes">The routes that navigators created from this factory will use when resolving requests.</param>
        public NavigatorFactory(string uriScheme, IRouteResolver routes)
        {
            uriScheme = uriScheme ?? "magellan";

            Guard.ArgumentNotNullOrEmpty(uriScheme, "uriScheme");
            Guard.ArgumentNotNull(routes, "routes");

            if (!Uri.CheckSchemeName(uriScheme))
            {
                throw new ArgumentException(string.Format("The scheme '{0}' is not a valid URI scheme.", uriScheme));
            }

            this.uriScheme = uriScheme;
            this.routes = routes;
        }
コード例 #26
0
ファイル: Producer.cs プロジェクト: mzabolotko/Contour
        /// <summary>
        /// Инициализирует новый экземпляр класса <see cref="Producer"/>.
        /// </summary>
        /// <param name="bus">
        /// Конечная точка, для которой создается отправитель.
        /// </param>
        /// <param name="label">
        /// Метка сообщения, которая будет использоваться при отправлении сообщений.
        /// </param>
        /// <param name="routeResolver">
        /// Определитель маршрутов, по которым можно отсылать и получать сообщения.
        /// </param>
        /// <param name="confirmationIsRequired">
        /// Если <c>true</c> - тогда отправитель будет ожидать подтверждения о том, что сообщение было сохранено в брокере.
        /// </param>
        public Producer(RabbitBus bus, MessageLabel label, IRouteResolver routeResolver, bool confirmationIsRequired)
        {
            this.Channel = bus.OpenChannel();
            this.Label = label;
            this.RouteResolver = routeResolver;
            this.ConfirmationIsRequired = confirmationIsRequired;

            if (this.ConfirmationIsRequired)
            {
                this.confirmationTracker = new DefaultPublishConfirmationTracker(this.Channel);
                this.Channel.EnablePublishConfirmation();
                this.Channel.OnConfirmation(this.confirmationTracker.HandleConfirmation);
            }

            this.Failed += _ => ((IBusAdvanced)bus).Panic();
        }
コード例 #27
0
        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>();

            A.CallTo(() => errorHandler.HandlesStatusCode(A<HttpStatusCode>.Ignored)).Returns(false);

            contextFactory = A.Fake<INancyContextFactory>();
            A.CallTo(() => contextFactory.Create()).Returns(context);

            A.CallTo(() => resolver.Resolve(A<NancyContext>.Ignored, A<IRouteCache>.Ignored)).Returns(new ResolveResult(route, DynamicDictionary.Empty, null, null));

            this.engine = new NancyEngine(resolver, A.Fake<IRouteCache>(), contextFactory, this.errorHandler);
        }
コード例 #28
0
        private static Response ExecuteDiagnostics(NancyContext ctx, IRouteResolver routeResolver, DiagnosticsConfiguration diagnosticsConfiguration, DefaultObjectSerializer serializer)
        {
            var session = GetSession(ctx, diagnosticsConfiguration, serializer);

            if (session == null)
            {
                var view = GetDiagnosticsLoginView(ctx);

                view.AddCookie(
                    new NancyCookie(DiagsCookieName, String.Empty, true)
                {
                    Expires = DateTime.Now.AddDays(-1)
                });

                return(view);
            }

            // TODO - duplicate the context and strip out the "_/Nancy" bit so we don't need to use it in the module
            var resolveResult = routeResolver.Resolve(ctx);

            ctx.Parameters = resolveResult.Item2;
            var resolveResultPreReq  = resolveResult.Item3;
            var resolveResultPostReq = resolveResult.Item4;

            ExecuteRoutePreReq(ctx, resolveResultPreReq);

            if (ctx.Response == null)
            {
                ctx.Response = resolveResult.Item1.Invoke(resolveResult.Item2);
            }

            if (ctx.Request.Method.ToUpperInvariant() == "HEAD")
            {
                ctx.Response = new HeadResponse(ctx.Response);
            }

            if (resolveResultPostReq != null)
            {
                resolveResultPostReq.Invoke(ctx);
            }

            AddUpdateSessionCookie(session, ctx, diagnosticsConfiguration, serializer);

            // If we duplicate the context this makes more sense :)
            return(ctx.Response);
        }
コード例 #29
0
 public ProxyMiddleware(
     RequestDelegate next,
     IRequestCreator requestCreator,
     IRequestSender sender,
     IResponseSender responseSender,
     IRouteResolver routeResolver,
     IExpressionEvaluator evaluator,
     ILogger <ProxyMiddleware> logger)
 {
     this.next           = CheckValue(next, nameof(next));
     this.requestCreator = CheckValue(requestCreator, nameof(requestCreator));
     this.sender         = CheckValue(sender, nameof(sender));
     this.responseSender = CheckValue(responseSender, nameof(responseSender));
     this.routeResolver  = CheckValue(routeResolver, nameof(routeResolver));
     this.evaluator      = CheckValue(evaluator, nameof(evaluator));
     this.logger         = CheckValue(logger, nameof(logger));
 }
コード例 #30
0
        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>();

            A.CallTo(() => errorHandler.HandlesStatusCode(A <HttpStatusCode> .Ignored)).Returns(false);

            contextFactory = A.Fake <INancyContextFactory>();
            A.CallTo(() => contextFactory.Create()).Returns(context);

            A.CallTo(() => resolver.Resolve(A <NancyContext> .Ignored, A <IRouteCache> .Ignored)).Returns(new ResolveResult(route, DynamicDictionary.Empty, null, null));

            this.engine = new NancyEngine(resolver, A.Fake <IRouteCache>(), contextFactory, this.errorHandler);
        }
コード例 #31
0
ファイル: DiagnosticsHook.cs プロジェクト: zxhgit/Nancy
        private static Response ExecuteDiagnostics(NancyContext ctx, IRouteResolver routeResolver, DiagnosticsConfiguration diagnosticsConfiguration, DefaultObjectSerializer serializer, INancyEnvironment environment)
        {
            var session = GetSession(ctx, diagnosticsConfiguration, serializer);

            if (session == null)
            {
                var view = GetDiagnosticsLoginView(ctx, environment);

                view.WithCookie(
                    new NancyCookie(diagnosticsConfiguration.CookieName, string.Empty, true)
                {
                    Expires = DateTime.Now.AddDays(-1)
                });

                return(view);
            }

            var resolveResult = routeResolver.Resolve(ctx);

            ctx.Parameters = resolveResult.Parameters;
            ExecuteRoutePreReq(ctx, CancellationToken, resolveResult.Before);

            if (ctx.Response == null)
            {
                var routeResult = resolveResult.Route.Invoke(resolveResult.Parameters, CancellationToken);
                routeResult.Wait();

                ctx.Response = (Response)routeResult.Result;
            }

            if (ctx.Request.Method.Equals("HEAD", StringComparison.OrdinalIgnoreCase))
            {
                ctx.Response = new HeadResponse(ctx.Response);
            }

            if (resolveResult.After != null)
            {
                resolveResult.After.Invoke(ctx, CancellationToken);
            }

            AddUpdateSessionCookie(session, ctx, diagnosticsConfiguration, serializer);

            return(ctx.Response);
        }
コード例 #32
0
        private static Response ExecuteDiagnostics(NancyContext ctx, IRouteResolver routeResolver, DiagnosticsConfiguration diagnosticsConfiguration, DefaultObjectSerializer serializer)
        {
            var session = GetSession(ctx, diagnosticsConfiguration, serializer);

            if (session == null)
            {
                var view = GetDiagnosticsLoginView(ctx);

                view.AddCookie(
                    new NancyCookie(diagnosticsConfiguration.CookieName, String.Empty, true)
                {
                    Expires = DateTime.Now.AddDays(-1)
                });

                return(view);
            }

            var resolveResult = routeResolver.Resolve(ctx);

            ctx.Parameters = resolveResult.Parameters;
            ExecuteRoutePreReq(ctx, CancellationToken, resolveResult.Before);

            if (ctx.Response == null)
            {
                // Don't care about async here, so just get the result
                var task = resolveResult.Route.Invoke(resolveResult.Parameters, CancellationToken);
                task.Wait();
                ctx.Response = task.Result;
            }

            if (ctx.Request.Method.ToUpperInvariant() == "HEAD")
            {
                ctx.Response = new HeadResponse(ctx.Response);
            }

            if (resolveResult.After != null)
            {
                resolveResult.After.Invoke(ctx, CancellationToken);
            }

            AddUpdateSessionCookie(session, ctx, diagnosticsConfiguration, serializer);

            return(ctx.Response);
        }
コード例 #33
0
        public NancyMetricsCollector(IRouteResolver routeResolver, IEnumerable <ISystemMetricCollector> collectors, NancyMetricsCollectorOptions options = null)
        {
            RouteResolver = routeResolver;
            Options       = options ?? new NancyMetricsCollectorOptions();

            ErrorRequestsProcessed   = Metrics.CreateCounter("server_request_error_total", "Number of unsuccessfull processed requests.", "method", "error_code");
            OngoingRequests          = Metrics.CreateGauge("server_request_in_progress", "Number of ongoing requests.", "method");
            RequestResponseHistogram = Metrics.CreateHistogram("server_request_duration_seconds", "Histogram of request duration in seconds.",
                                                               new HistogramConfiguration()
            {
                LabelNames = new string[] { "method" },
                Buckets    = Options.Buckets
            });
            var registry = Metrics.DefaultRegistry;

            foreach (var collector in collectors)
            {
                registry.AddBeforeCollectCallback(collector.UpdateMetrics);
            }
        }
コード例 #34
0
ファイル: NancyEngineFixture.cs プロジェクト: zxhgit/Nancy
        public NancyEngineFixture()
        {
            this.environment =
                new DefaultNancyEnvironment();

            this.environment.Tracing(
                enabled: true,
                displayErrorTraces: true);

            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.negotiator        = A.Fake <IResponseNegotiator>();

            A.CallTo(() => this.requestDispatcher.Dispatch(A <NancyContext> ._, A <CancellationToken> ._))
            .Returns(Task.FromResult(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>();

            this.engine =
                new NancyEngine(this.requestDispatcher, this.contextFactory, new[] { this.statusCodeHandler }, A.Fake <IRequestTracing>(), new DisabledStaticContentProvider(), this.negotiator, this.environment)
            {
                RequestPipelinesFactory = ctx => applicationPipelines
            };
        }
コード例 #35
0
            public FakeEngine(IRouteResolver resolver, IRouteCache routeCache, INancyContextFactory contextFactory)
            {
                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");
                }

                this.resolver       = resolver;
                this.routeCache     = routeCache;
                this.contextFactory = contextFactory;
            }
コード例 #36
0
ファイル: NancyEngine.cs プロジェクト: ToJans/Nancy
        /// <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>
        public NancyEngine(IRouteResolver resolver, IRouteCache routeCache, INancyContextFactory contextFactory)
        {
            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");
            }

            this.resolver = resolver;
            this.routeCache = routeCache;
            this.contextFactory = contextFactory;
        }
コード例 #37
0
        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(
                new FakeRoute(),
                DynamicDictionary.Empty,
                null,
                null);

            A.CallTo(() => this.routeResolver.Resolve(A <NancyContext> ._)).Returns(resolvedRoute);
        }
コード例 #38
0
        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(arg =>
            {
                var tcs = new TaskCompletionSource <Response>();

                var actionResult =
                    ((Route)arg.Arguments[0]).Action.Invoke(arg.Arguments[2], new CancellationToken());

                if (actionResult.IsFaulted)
                {
                    tcs.SetException(actionResult.Exception.InnerException);
                }
                else
                {
                    tcs.SetResult(actionResult.Result);
                }
                return(tcs.Task);
            });

            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);
        }
コード例 #39
0
        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> ._))
            .Returns(CreateResponseTask(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
            };
        }
コード例 #40
0
ファイル: NancyEngine.cs プロジェクト: skinny/Nancy
        /// <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="contextFactory">A factory for creating contexts</param>
        /// <param name="errorHandlers">Error handlers</param>
        public NancyEngine(IRouteResolver resolver, INancyContextFactory contextFactory, IEnumerable <IErrorHandler> errorHandlers, IRequestTracing requestTracing)
        {
            if (resolver == null)
            {
                throw new ArgumentNullException("resolver", "The resolver parameter cannot be null.");
            }

            if (contextFactory == null)
            {
                throw new ArgumentNullException("contextFactory");
            }

            if (errorHandlers == null)
            {
                throw new ArgumentNullException("errorHandlers");
            }

            this.resolver       = resolver;
            this.contextFactory = contextFactory;
            this.errorHandlers  = errorHandlers;
            this.requestTracing = requestTracing;
        }
コード例 #41
0
        public NancyEngineFixture()
        {
            this.environment =
                new DefaultNancyEnvironment();

            this.environment.Tracing(
                enabled: true,
                displayErrorTraces: true);

            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.negotiator = A.Fake<IResponseNegotiator>();

            A.CallTo(() => this.requestDispatcher.Dispatch(A<NancyContext>._, A<CancellationToken>._))
                .Returns(Task.FromResult(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>();

            this.engine =
                new NancyEngine(this.requestDispatcher, this.contextFactory, new[] { this.statusCodeHandler }, A.Fake<IRequestTracing>(), new DisabledStaticContentProvider(), this.negotiator, this.environment)
                {
                    RequestPipelinesFactory = ctx => applicationPipelines
                };
        }
コード例 #42
0
        /// <summary>
        /// The resolve for.
        /// </summary>
        /// <param name="configuration">
        /// The configuration.
        /// </param>
        /// <returns>
        /// The <see cref="Producer"/>.
        /// </returns>
        public Producer ResolveFor(ISenderConfiguration configuration)
        {
            Producer producer = this.TryResolverFor(configuration.Label);

            if (producer == null)
            {
                using (RabbitChannel channel = this._bus.OpenChannel())
                {
                    var topologyBuilder = new TopologyBuilder(channel);
                    var builder         = new RouteResolverBuilder(this._bus.Endpoint, topologyBuilder, configuration);
                    Maybe <Func <IRouteResolverBuilder, IRouteResolver> > routeResolverBuilder = configuration.Options.GetRouteResolverBuilder();

                    Assumes.True(routeResolverBuilder.HasValue, "RouteResolverBuilder must be set for [{0}]", configuration.Label);

                    IRouteResolver routeResolver = routeResolverBuilder.Value(builder);

                    producer         = new Producer(this._bus, configuration.Label, routeResolver, configuration.Options.IsConfirmationRequired());
                    producer.Failed += p =>
                    {
                        {
                            // lock (_producers)
                            p.Dispose();
                            this._producers.Remove(p.Label);
                        }
                    };

                    // lock (_producers)
                    this._producers.Add(configuration.Label, producer);
                }

                if (configuration.RequiresCallback)
                {
                    producer.UseCallbackListener(this._bus.ListenerRegistry.ResolveFor(configuration.CallbackConfiguration));
                }
            }

            return(producer);
        }
コード例 #43
0
        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>();

            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));

            var applicationPipelines = new Pipelines();

            this.engine =
                new NancyEngine(resolver, contextFactory, new[] { this.errorHandler }, A.Fake <IRequestTracing>())
            {
                RequestPipelinesFactory = ctx => applicationPipelines
            };
        }
コード例 #44
0
        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>();

            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));

            var applicationPipelines = new Pipelines();

            this.engine =
                new NancyEngine(resolver, contextFactory, new[] { this.errorHandler }, A.Fake<IRequestTracing>())
                {
                    RequestPipelinesFactory = ctx => applicationPipelines
                };
        }
コード例 #45
0
 public DefaultActionBuilder(IRouteResolver actionResolver, IControllerActivator controllerActivator)
 {
     _actionResolver      = actionResolver;
     _controllerActivator = controllerActivator;
 }
コード例 #46
0
 /// <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>
 public DefaultRequestDispatcher(IRouteResolver routeResolver, IEnumerable <IResponseProcessor> responseProcessors, IRouteInvoker routeInvoker)
 {
     this.routeResolver      = routeResolver;
     this.responseProcessors = responseProcessors;
     this.routeInvoker       = routeInvoker;
 }
コード例 #47
0
 public FakeEngine(IRouteResolver resolver, IRouteCache routeCache, INancyContextFactory contextFactory)
 {
     Resolver       = resolver ?? throw new ArgumentNullException(nameof(resolver), "The resolver parameter cannot be null.");
     RouteCache     = routeCache ?? throw new ArgumentNullException(nameof(routeCache), "The routeCache parameter cannot be null.");
     ContextFactory = contextFactory ?? throw new ArgumentNullException(nameof(contextFactory));
 }
コード例 #48
0
 public Request(IRootPathProvider rootPath, IRouteResolver routeResolver)
 {
     this.rootPath      = rootPath;
     this.routeResolver = routeResolver;
 }
コード例 #49
0
 public Entity(IEventStream stream, IRouteResolver resolver)
 {
     (this as INeedStream).Stream          = stream;
     (this as INeedRouteResolver).Resolver = resolver;
 }
コード例 #50
0
 /// <summary>
 /// Инициализирует новый экземпляр класса <see cref="SubscriptionEndpoint"/>.
 /// </summary>
 /// <param name="listeningSource">
 /// The listening source.
 /// </param>
 /// <param name="callbackRouteResolver">
 /// The callback route resolver.
 /// </param>
 public SubscriptionEndpoint(IListeningSource listeningSource, IRouteResolver callbackRouteResolver = null)
 {
     this.ListeningSource       = listeningSource;
     this.CallbackRouteResolver = callbackRouteResolver;
 }
コード例 #51
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="nancyBootstrapper"></param>
 /// <param name="routeResolver"></param>
 /// <param name="pipelines"></param>
 /// <param name="varyParams"> </param>
 public static void Enable(INancyBootstrapper nancyBootstrapper, IRouteResolver routeResolver,
                           IPipelines pipelines)
 => Enable(nancyBootstrapper, routeResolver, pipelines, new DefaultCacheKeyGenerator(),
           new MemoryCacheStore());
コード例 #52
0
ファイル: Producer.cs プロジェクト: forki/Contour
        /// <summary>
        /// Initializes a new instance of the <see cref="Producer"/> class.
        /// </summary>
        /// <param name="endpoint">
        /// The endpoint.
        /// </param>
        /// <param name="connection">
        /// Соединение с шиной сообщений
        /// </param>
        /// <param name="label">
        /// Метка сообщения, которая будет использоваться при отправлении сообщений.
        /// </param>
        /// <param name="routeResolver">
        /// Определитель маршрутов, по которым можно отсылать и получать сообщения.
        /// </param>
        /// <param name="confirmationIsRequired">
        /// Если <c>true</c> - тогда отправитель будет ожидать подтверждения о том, что сообщение было сохранено в брокере.
        /// </param>
        public Producer(IEndpoint endpoint, IRabbitConnection connection, MessageLabel label, IRouteResolver routeResolver, bool confirmationIsRequired)
        {
            this.endpoint = endpoint;

            this.connection             = connection;
            this.BrokerUrl              = connection.ConnectionString;
            this.Label                  = label;
            this.RouteResolver          = routeResolver;
            this.ConfirmationIsRequired = confirmationIsRequired;

            this.logger = LogManager.GetLogger($"{this.GetType().FullName}({this.BrokerUrl}, {this.Label}, {this.GetHashCode()})");
        }
コード例 #53
0
 public RestfulDbMiddleware(RequestDelegate next, IRouteResolver routeResolver, IDatabaseHandler dbHandler)
 {
     this.next          = next;
     this.routeResolver = routeResolver;
     this.dbHandler     = dbHandler;
 }
コード例 #54
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Navigator"/> class.
        /// </summary>
        /// <param name="factory">The factory that created this navigator.</param>
        /// <param name="parent">The parent navigator (can be null).</param>
        /// <param name="scheme">The URI scheme.</param>
        /// <param name="routes">The routes.</param>
        /// <param name="navigationService">The navigation service.</param>
        public Navigator(INavigatorFactory factory, INavigator parent, string scheme, IRouteResolver routes, Func <INavigationService> navigationService)
            : base(navigationService)
        {
            Guard.ArgumentNotNull(factory, "root");
            Guard.ArgumentNotNull(routes, "routes");
            Guard.ArgumentNotNull(navigationService, "navigationService");

            this.factory = factory;
            this.parent  = parent;
            this.scheme  = scheme;
            this.routes  = routes;
        }
コード例 #55
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NavigatorFactory"/> class.
 /// </summary>
 /// <param name="routes">The routes that navigators created from this factory will use when resolving requests.</param>
 public NavigatorFactory(IRouteResolver routes)
     : this(null, routes)
 {
 }
コード例 #56
0
ファイル: PomonaStartup.cs プロジェクト: anthrax3/Pomona
 public PomonaStartup(IRouteResolver routeResolver)
 {
     this.routeResolver = routeResolver;
 }
コード例 #57
0
 /// <summary>
 /// Создает подписку на получение ответных сообщений для указанного источника.
 /// </summary>
 /// <param name="listeningSource">Источник ответных сообщений.</param>
 /// <param name="callbackRouteResolver">Вычислитель маршрута ответного сообщения.</param>
 /// <returns>Конечная точка подписки.</returns>
 public ISubscriptionEndpoint ListenTo(IListeningSource listeningSource, IRouteResolver callbackRouteResolver)
 {
     return(new SubscriptionEndpoint(listeningSource, callbackRouteResolver));
 }
コード例 #58
0
ファイル: Producer.cs プロジェクト: Sliborskii/Contour
        /// <summary>
        /// Initializes a new instance of the <see cref="Producer"/> class.
        /// </summary>
        /// <param name="endpoint">
        /// The endpoint.
        /// </param>
        /// <param name="connection">
        /// Соединение с шиной сообщений
        /// </param>
        /// <param name="label">
        /// Метка сообщения, которая будет использоваться при отправлении сообщений.
        /// </param>
        /// <param name="routeResolver">
        /// Определитель маршрутов, по которым можно отсылать и получать сообщения.
        /// </param>
        /// <param name="confirmationIsRequired">
        /// Если <c>true</c> - тогда отправитель будет ожидать подтверждения о том, что сообщение было сохранено в брокере.
        /// </param>
        public Producer(IEndpoint endpoint, IRabbitConnection connection, MessageLabel label, IRouteResolver routeResolver, bool confirmationIsRequired)
        {
            this.endpoint = endpoint;

            this.Channel   = connection.OpenChannel();
            this.BrokerUrl = connection.ConnectionString;
            this.logger    = LogManager.GetLogger($"{this.GetType().FullName}(URL={this.BrokerUrl})");

            this.Label                  = label;
            this.RouteResolver          = routeResolver;
            this.ConfirmationIsRequired = confirmationIsRequired;

            if (this.ConfirmationIsRequired)
            {
                this.confirmationTracker = new DefaultPublishConfirmationTracker(this.Channel);
                this.Channel.EnablePublishConfirmation();
                this.Channel.OnConfirmation(this.confirmationTracker.HandleConfirmation);
            }
        }
コード例 #59
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="nancyBootstrapper"></param>
 /// <param name="routeResolver"></param>
 /// <param name="pipelines"></param>
 /// <param name="cacheKeyGenerator"></param>
 public static void Enable(INancyBootstrapper nancyBootstrapper, IRouteResolver routeResolver, IPipelines pipelines, ICacheKeyGenerator cacheKeyGenerator)
 {
     Enable(nancyBootstrapper, routeResolver, pipelines, cacheKeyGenerator, new WebCacheStore());
 }
コード例 #60
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="nancyBootstrapper"></param>
 /// <param name="routeResolver"></param>
 /// <param name="pipelines"></param>
 /// <param name="varyParams"> </param>
 public static void Enable(INancyBootstrapper nancyBootstrapper, IRouteResolver routeResolver, IPipelines pipelines, string[] varyParams)
 {
     Enable(nancyBootstrapper, routeResolver, pipelines, new DefaultCacheKeyGenerator(varyParams), new WebCacheStore());
 }