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


C# Diagnostics.DiagnosticsConfiguration类代码示例

本文整理汇总了C#中Nancy.Diagnostics.DiagnosticsConfiguration的典型用法代码示例。如果您正苦于以下问题:C# DiagnosticsConfiguration类的具体用法?C# DiagnosticsConfiguration怎么用?C# DiagnosticsConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DiagnosticsConfiguration类属于Nancy.Diagnostics命名空间,在下文中一共展示了DiagnosticsConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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>._)).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);

            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, this.contextFactory, new[] { this.statusCodeHandler }, A.Fake<IRequestTracing>(), this.diagnosticsConfiguration, new DisabledStaticContentProvider())
                {
                    RequestPipelinesFactory = ctx => applicationPipelines
                };
        }
开发者ID:jvanzella,项目名称:Nancy,代码行数:34,代码来源:NancyEngineFixture.cs

示例2: ConfigureContainer

        private static TinyIoCContainer ConfigureContainer(IModuleKeyGenerator moduleKeyGenerator, IEnumerable<IDiagnosticsProvider> providers, IRootPathProvider rootPathProvider, IRequestTracing requestTracing, NancyInternalConfiguration configuration, DiagnosticsConfiguration diagnosticsConfiguration)
        {
            var diagContainer = new TinyIoCContainer();

            diagContainer.Register<IModuleKeyGenerator>(moduleKeyGenerator);
            diagContainer.Register<IInteractiveDiagnostics, InteractiveDiagnostics>();
            diagContainer.Register<IRequestTracing>(requestTracing);
            diagContainer.Register<IRootPathProvider>(rootPathProvider);
            diagContainer.Register<NancyInternalConfiguration>(configuration);
            diagContainer.Register<IModelBinderLocator, DefaultModelBinderLocator>();
            diagContainer.Register<IBinder, DefaultBinder>();
            diagContainer.Register<IFieldNameConverter, DefaultFieldNameConverter>();
            diagContainer.Register<BindingDefaults, BindingDefaults>();
            diagContainer.Register<ISerializer, DefaultJsonSerializer>();
            diagContainer.Register<DiagnosticsConfiguration>(diagnosticsConfiguration);

            foreach (var diagnosticsProvider in providers)
            {
                diagContainer.Register<IDiagnosticsProvider>(diagnosticsProvider, diagnosticsProvider.GetType().FullName);
            }

            foreach (var moduleType in AppDomainAssemblyTypeScanner.TypesOf<DiagnosticModule>().ToArray())
            {
                diagContainer.Register(typeof(NancyModule), moduleType, moduleKeyGenerator.GetKeyForModuleType(moduleType)).AsMultiInstance();
            }

            return diagContainer;
        }
开发者ID:rhwy,项目名称:Nancy,代码行数:28,代码来源:DiagnosticsModuleCatalog.cs

示例3: DefaultDiagnostics

 /// <summary>
 /// Creates a new instance of the <see cref="DefaultDiagnostics"/> class.
 /// </summary>
 /// <param name="diagnosticsConfiguration"></param>
 /// <param name="diagnosticProviders"></param>
 /// <param name="rootPathProvider"></param>
 /// <param name="requestTracing"></param>
 /// <param name="configuration"></param>
 /// <param name="modelBinderLocator"></param>
 /// <param name="responseProcessors"></param>
 /// <param name="routeSegmentConstraints"></param>
 /// <param name="cultureService"></param>
 /// <param name="requestTraceFactory"></param>
 /// <param name="routeMetadataProviders"></param>
 /// <param name="textResource"></param>
 public DefaultDiagnostics(
     DiagnosticsConfiguration diagnosticsConfiguration,
     IEnumerable<IDiagnosticsProvider> diagnosticProviders,
     IRootPathProvider rootPathProvider,
     IRequestTracing requestTracing,
     NancyInternalConfiguration configuration,
     IModelBinderLocator modelBinderLocator,
     IEnumerable<IResponseProcessor> responseProcessors,
     IEnumerable<IRouteSegmentConstraint> routeSegmentConstraints,
     ICultureService cultureService,
     IRequestTraceFactory requestTraceFactory,
     IEnumerable<IRouteMetadataProvider> routeMetadataProviders,
     ITextResource textResource)
 {
     this.diagnosticsConfiguration = diagnosticsConfiguration;
     this.diagnosticProviders = diagnosticProviders;
     this.rootPathProvider = rootPathProvider;
     this.requestTracing = requestTracing;
     this.configuration = configuration;
     this.modelBinderLocator = modelBinderLocator;
     this.responseProcessors = responseProcessors;
     this.routeSegmentConstraints = routeSegmentConstraints;
     this.cultureService = cultureService;
     this.requestTraceFactory = requestTraceFactory;
     this.routeMetadataProviders = routeMetadataProviders;
     this.textResource = textResource;
 }
开发者ID:DarrellMozingo,项目名称:Nancy,代码行数:42,代码来源:DefaultDiagnostics.cs

示例4: NancyEngine

        /// <summary>
        /// Initializes a new instance of the <see cref="NancyEngine"/> class.
        /// </summary>
        /// <param name="dispatcher">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="statusCodeHandlers">Error handlers</param>
        /// <param name="requestTracing">The request tracing instance.</param>
        /// <param name="diagnosticsConfiguration"></param>
        /// <param name="staticContentProvider">The provider to use for serving static content</param>
        public NancyEngine(IRequestDispatcher dispatcher, INancyContextFactory contextFactory, IEnumerable<IStatusCodeHandler> statusCodeHandlers, IRequestTracing requestTracing, DiagnosticsConfiguration diagnosticsConfiguration, IStaticContentProvider staticContentProvider)
        {
            if (dispatcher == null)
            {
                throw new ArgumentNullException("dispatcher", "The resolver parameter cannot be null.");
            }

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

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

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

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

            this.dispatcher = dispatcher;
            this.contextFactory = contextFactory;
            this.statusCodeHandlers = statusCodeHandlers;
            this.requestTracing = requestTracing;
            this.diagnosticsConfiguration = diagnosticsConfiguration;
            this.staticContentProvider = staticContentProvider;
        }
开发者ID:vhuabigger,项目名称:Nancy,代码行数:43,代码来源:NancyEngine.cs

示例5: Enable

        public static void Enable(DiagnosticsConfiguration diagnosticsConfiguration, IPipelines pipelines, IEnumerable<IDiagnosticsProvider> providers, IRootPathProvider rootPathProvider, IEnumerable<ISerializer> serializers, IRequestTracing requestTracing, NancyInternalConfiguration configuration, IModelBinderLocator modelBinderLocator, IEnumerable<IResponseProcessor> responseProcessors, ICultureService cultureService)
        {
            var keyGenerator = new DefaultModuleKeyGenerator();
            var diagnosticsModuleCatalog = new DiagnosticsModuleCatalog(keyGenerator, providers, rootPathProvider, requestTracing, configuration, diagnosticsConfiguration);

            var diagnosticsRouteCache = new RouteCache(diagnosticsModuleCatalog, keyGenerator, new DefaultNancyContextFactory(cultureService), new DefaultRouteSegmentExtractor(), new DefaultRouteDescriptionProvider(), cultureService);

            var diagnosticsRouteResolver = new DefaultRouteResolver(
                diagnosticsModuleCatalog,
                new DefaultRoutePatternMatcher(),
                new DiagnosticsModuleBuilder(rootPathProvider, serializers, modelBinderLocator),
                diagnosticsRouteCache,
                responseProcessors);

            var serializer = new DefaultObjectSerializer();

            pipelines.BeforeRequest.AddItemToStartOfPipeline(
                new PipelineItem<Func<NancyContext, Response>>(
                    PipelineKey,
                    ctx =>
                    {
                        if (!ctx.ControlPanelEnabled)
                        {
                            return null;
                        }

                        if (!ctx.Request.Path.StartsWith(diagnosticsConfiguration.Path, StringComparison.OrdinalIgnoreCase))
                        {
                            return null;
                        }

                        ctx.Items[ItemsKey] = true;

                        var resourcePrefix =
                            string.Concat(diagnosticsConfiguration.Path, "/Resources/");

                        if (ctx.Request.Path.StartsWith(resourcePrefix, StringComparison.OrdinalIgnoreCase))
                        {
                            var resourceNamespace = "Nancy.Diagnostics.Resources";

                            var path = Path.GetDirectoryName(ctx.Request.Url.Path.Replace(resourcePrefix, string.Empty)) ?? string.Empty;
                            if (!string.IsNullOrEmpty(path))
                            {
                                resourceNamespace += string.Format(".{0}", path.Replace('\\', '.'));
                            }

                            return new EmbeddedFileResponse(
                                typeof(DiagnosticsHook).Assembly,
                                resourceNamespace,
                                Path.GetFileName(ctx.Request.Url.Path));
                        }

                        RewriteDiagnosticsUrl(diagnosticsConfiguration, ctx);

                        return diagnosticsConfiguration.Valid
                                   ? ExecuteDiagnostics(ctx, diagnosticsRouteResolver, diagnosticsConfiguration, serializer)
                                   : GetDiagnosticsHelpView(ctx);
                    }));
        }
开发者ID:jvanzella,项目名称:Nancy,代码行数:59,代码来源:DiagnosticsHook.cs

示例6: Should_return_info_page_if_password_null

        public void Should_return_info_page_if_password_null()
        {
            var diagsConfig = new DiagnosticsConfiguration { Password = null, CryptographyConfiguration = this.cryptoConfig };
            var bootstrapper = new ConfigurableBootstrapper(b => b.DiagnosticsConfiguration(diagsConfig));
            var browser = new Browser(bootstrapper);

            var result = browser.Get("/_Nancy");

            Assert.True(result.Body.AsString().Contains("Diagnostics Disabled"));
        }
开发者ID:RobertTheGrey,项目名称:Nancy,代码行数:10,代码来源:DiagnosticsHookFixture.cs

示例7: DiagnosticsApplicationStartup

 public DiagnosticsApplicationStartup(DiagnosticsConfiguration diagnosticsConfiguration, IEnumerable<IDiagnosticsProvider> diagnosticProviders, IRootPathProvider rootPathProvider, IEnumerable<ISerializer> serializers, IRequestTracing requestTracing, NancyInternalConfiguration configuration, IModelBinderLocator modelBinderLocator)
 {
     this.diagnosticsConfiguration = diagnosticsConfiguration;
     this.diagnosticProviders = diagnosticProviders;
     this.rootPathProvider = rootPathProvider;
     this.serializers = serializers;
     this.requestTracing = requestTracing;
     this.configuration = configuration;
     this.modelBinderLocator = modelBinderLocator;
 }
开发者ID:ktairov,项目名称:Nancy,代码行数:10,代码来源:DiagnosticsApplicationStartup.cs

示例8: DefaultDiagnostics

 public DefaultDiagnostics(DiagnosticsConfiguration diagnosticsConfiguration, IEnumerable<IDiagnosticsProvider> diagnosticProviders, IRootPathProvider rootPathProvider, IRequestTracing requestTracing, NancyInternalConfiguration configuration, IModelBinderLocator modelBinderLocator, IEnumerable<IResponseProcessor> responseProcessors, ICultureService cultureService)
 {
     this.diagnosticsConfiguration = diagnosticsConfiguration;
     this.diagnosticProviders = diagnosticProviders;
     this.rootPathProvider = rootPathProvider;
     this.requestTracing = requestTracing;
     this.configuration = configuration;
     this.modelBinderLocator = modelBinderLocator;
     this.responseProcessors = responseProcessors;
     this.cultureService = cultureService;
 }
开发者ID:lukywong,项目名称:Nancy,代码行数:11,代码来源:DefaultDiagnostics.cs

示例9: Should_return_login_page_with_auth_cookie_with_incorrect_password

        public void Should_return_login_page_with_auth_cookie_with_incorrect_password()
        {
            var diagsConfig = new DiagnosticsConfiguration { Password = "password", CryptographyConfiguration = this.cryptoConfig };
            var bootstrapper = new ConfigurableBootstrapper(b => b.DiagnosticsConfiguration(diagsConfig));
            var browser = new Browser(bootstrapper);

            var result = browser.Get("/_Nancy", with =>
            {
                with.Cookie(DiagsCookieName, this.GetSessionCookieValue("wrongPassword"));
            });

            result.Body["#login"].ShouldExistOnce();
        }
开发者ID:RobertTheGrey,项目名称:Nancy,代码行数:13,代码来源:DiagnosticsHookFixture.cs

示例10: Should_not_accept_invalid_password

        public void Should_not_accept_invalid_password()
        {
            var diagsConfig = new DiagnosticsConfiguration { Password = "password", CryptographyConfiguration = this.cryptoConfig };
            var bootstrapper = new ConfigurableBootstrapper(b => b.DiagnosticsConfiguration(diagsConfig));
            var browser = new Browser(bootstrapper);

            var result = browser.Post("/_Nancy", with =>
            {
                with.FormValue("Password", "wrongpassword");
            });

            result.Body["#login"].ShouldExistOnce();
            result.Cookies.Any(c => c.Name == DiagsCookieName && !string.IsNullOrEmpty(c.Value)).ShouldBeFalse();
        }
开发者ID:RobertTheGrey,项目名称:Nancy,代码行数:14,代码来源:DiagnosticsHookFixture.cs

示例11: NancyEngineWithAsyncCancellation

		public NancyEngineWithAsyncCancellation(
			IRequestDispatcher requestDispatcher,
			INancyContextFactory nancyContextFactory,
			IEnumerable<IStatusCodeHandler> statusCodeHandlers,
			IRequestTracing requestTracing,
			DiagnosticsConfiguration diagnosticsConfiguration,
			IStaticContentProvider staticContentProvider)
		{
			this.engine = new NancyEngine(
				requestDispatcher,
				nancyContextFactory,
				statusCodeHandlers,
				requestTracing,
				diagnosticsConfiguration,
				staticContentProvider);
		}
开发者ID:serenata-evaldas,项目名称:Nancy.ServiceRouting,代码行数:16,代码来源:NancyEngineWithAsyncCancellation.cs

示例12: Should_return_info_page_if_password_null

        public void Should_return_info_page_if_password_null()
        {
            // Given
            var diagsConfig = new DiagnosticsConfiguration { Password = null, CryptographyConfiguration = this.cryptoConfig };

            var bootstrapper = new ConfigurableBootstrapper(with =>{
                with.EnableAutoRegistration();
                with.DiagnosticsConfiguration(diagsConfig);
            });

            var browser = new Browser(bootstrapper);

            // When
            var result = browser.Get("/_Nancy");

            // Then
            Assert.True(result.Body.AsString().Contains("Diagnostics Disabled"));
        }
开发者ID:ktairov,项目名称:Nancy,代码行数:18,代码来源:DiagnosticsHookFixture.cs

示例13: Should_return_login_page_with_no_auth_cookie

        public void Should_return_login_page_with_no_auth_cookie()
        {
            // Given
            var diagsConfig = new DiagnosticsConfiguration { Password = "password", CryptographyConfiguration = this.cryptoConfig };

            var bootstrapper = new ConfigurableBootstrapper(with =>
            {
                with.EnableAutoRegistration();
                with.DiagnosticsConfiguration(diagsConfig);
                with.Diagnostics<DefaultDiagnostics>();
            });

            var browser = new Browser(bootstrapper);

            // When
            var result = browser.Get(diagsConfig.Path);

            // Then
            result.Body["#login"].ShouldExistOnce();
        }
开发者ID:Borzoo,项目名称:Nancy,代码行数:20,代码来源:DiagnosticsHookFixture.cs

示例14: Should_return_main_page_with_valid_auth_cookie

        public void Should_return_main_page_with_valid_auth_cookie()
        {
            // Given
            var diagsConfig = new DiagnosticsConfiguration { Password = "password", CryptographyConfiguration = this.cryptoConfig };

            var bootstrapper = new ConfigurableBootstrapper(with =>
            {
                with.EnableAutoRegistration();
                with.DiagnosticsConfiguration(diagsConfig);
                with.Diagnostics<FakeDiagnostics>();
            });

            var browser = new Browser(bootstrapper);

            // When
            var result = browser.Get(diagsConfig.Path + "/interactive/providers/", with =>
                {
                    with.Cookie(DiagsCookieName, this.GetSessionCookieValue("password"));
                });

            // Then should see our fake provider and not the default testing provider
            result.Body.AsString().ShouldContain("Fake testing provider");
            result.Body.AsString().ShouldNotContain("Testing Diagnostic Provider");
        }
开发者ID:BredStik,项目名称:Nancy,代码行数:24,代码来源:CustomInteractiveDiagnosticsFixture.cs

示例15: AddUpdateSessionCookie

        private static void AddUpdateSessionCookie(DiagnosticsSession session, NancyContext context, DiagnosticsConfiguration diagnosticsConfiguration, DefaultObjectSerializer serializer)
        {
            if (context.Response == null)
            {
                return;
            }

            session.Expiry = DateTime.Now.AddMinutes(diagnosticsConfiguration.SlidingTimeout);
            var serializedSession = serializer.Serialize(session);

            var encryptedSession = diagnosticsConfiguration.CryptographyConfiguration.EncryptionProvider.Encrypt(serializedSession);
            var hmacBytes = diagnosticsConfiguration.CryptographyConfiguration.HmacProvider.GenerateHmac(encryptedSession);
            var hmacString = Convert.ToBase64String(hmacBytes);

            var cookie = new NancyCookie(diagnosticsConfiguration.CookieName, String.Format("{1}{0}", encryptedSession, hmacString), true);

            context.Response.AddCookie(cookie);
        }
开发者ID:adglopez,项目名称:Nancy,代码行数:18,代码来源:DiagnosticsHook.cs


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