public RazorViewEngineFixture() { this.configuration = A.Fake<IRazorConfiguration>(); this.textResource = A.Fake<ITextResource>(); this.engine = new RazorViewEngine(this.configuration, this.textResource); var cache = A.Fake<IViewCache>(); A.CallTo(() => cache.GetOrAdd(A<ViewLocationResult>.Ignored, A<Func<ViewLocationResult, Func<NancyRazorViewBase>>>.Ignored)) .ReturnsLazily(x => { var result = x.GetArgument<ViewLocationResult>(0); return x.GetArgument<Func<ViewLocationResult, Func<NancyRazorViewBase>>>(1).Invoke(result); }); this.renderContext = A.Fake<IRenderContext>(); A.CallTo(() => this.renderContext.ViewCache).Returns(cache); A.CallTo(() => this.renderContext.LocateView(A<string>.Ignored, A<object>.Ignored)) .ReturnsLazily(x => { var viewName = x.GetArgument<string>(0); return FindView(viewName); ; }); this.rootPathProvider = A.Fake<IRootPathProvider>(); A.CallTo(() => this.rootPathProvider.GetRootPath()).Returns(Path.Combine(Environment.CurrentDirectory, "TestViews")); this.fileSystemViewLocationProvider = new FileSystemViewLocationProvider(this.rootPathProvider, new DefaultFileSystemReader()); }
public RazorViewEngineFixture() { this.configuration = A.Fake <IRazorConfiguration>(); this.textResource = A.Fake <ITextResource>(); this.engine = new RazorViewEngine(this.configuration, this.textResource); var cache = A.Fake <IViewCache>(); A.CallTo(() => cache.GetOrAdd(A <ViewLocationResult> .Ignored, A <Func <ViewLocationResult, Func <NancyRazorViewBase> > > .Ignored)) .ReturnsLazily(x => { var result = x.GetArgument <ViewLocationResult>(0); return(x.GetArgument <Func <ViewLocationResult, Func <NancyRazorViewBase> > >(1).Invoke(result)); }); this.renderContext = A.Fake <IRenderContext>(); A.CallTo(() => this.renderContext.ViewCache).Returns(cache); A.CallTo(() => this.renderContext.LocateView(A <string> .Ignored, A <object> .Ignored)) .ReturnsLazily(x => { var viewName = x.GetArgument <string>(0); return(FindView(viewName));; }); this.rootPathProvider = A.Fake <IRootPathProvider>(); A.CallTo(() => this.rootPathProvider.GetRootPath()).Returns(Path.Combine(Environment.CurrentDirectory, "TestViews")); this.fileSystemViewLocationProvider = new FileSystemViewLocationProvider(this.rootPathProvider, new DefaultFileSystemReader()); }
public FakeDiagnostics( IRootPathProvider rootPathProvider, IRequestTracing requestTracing, NancyInternalConfiguration configuration, IModelBinderLocator modelBinderLocator, IEnumerable <IResponseProcessor> responseProcessors, IEnumerable <IRouteSegmentConstraint> routeSegmentConstraints, ICultureService cultureService, IRequestTraceFactory requestTraceFactory, IEnumerable <IRouteMetadataProvider> routeMetadataProviders, ITextResource textResource, INancyEnvironment environment, ITypeCatalog typeCatalog) { this.diagnosticProviders = (new IDiagnosticsProvider[] { new FakeDiagnosticsProvider() }).ToArray(); 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; this.environment = environment; this.typeCatalog = typeCatalog; }
/// <summary> /// Creates a new instance of the <see cref="DefaultDiagnostics"/> class. /// </summary> /// <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> /// <param name="environment"></param> /// <param name="typeCatalog"></param> public DefaultDiagnostics( 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, INancyEnvironment environment, ITypeCatalog typeCatalog) { 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; this.environment = environment; this.typeCatalog = typeCatalog; }
/// <summary> /// Creates a new instance of the <see cref="DefaultNancyContextFactory"/> class. /// </summary> /// <param name="cultureService">An <see cref="ICultureService"/> instance.</param> /// <param name="requestTraceFactory">An <see cref="IRequestTraceFactory"/> instance.</param> /// <param name="textResource">An <see cref="ITextResource"/> instance.</param> /// <param name="environment">An <see cref="INancyEnvironment"/> instance.</param> public DefaultNancyContextFactory(ICultureService cultureService, IRequestTraceFactory requestTraceFactory, ITextResource textResource, INancyEnvironment environment) { this.cultureService = cultureService; this.requestTraceFactory = requestTraceFactory; this.textResource = textResource; this.environment = environment; }
public FakeDiagnostics( IRootPathProvider rootPathProvider, IRequestTracing requestTracing, NancyInternalConfiguration configuration, IModelBinderLocator modelBinderLocator, IEnumerable<IResponseProcessor> responseProcessors, IEnumerable<IRouteSegmentConstraint> routeSegmentConstraints, ICultureService cultureService, IRequestTraceFactory requestTraceFactory, IEnumerable<IRouteMetadataProvider> routeMetadataProviders, ITextResource textResource, INancyEnvironment environment, IRuntimeEnvironmentInformation runtimeEnvironmentInformation) { this.diagnosticProviders = (new IDiagnosticsProvider[] { new FakeDiagnosticsProvider() }).ToArray(); 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; this.environment = environment; this.runtimeEnvironmentInformation = runtimeEnvironmentInformation; }
public PactAwareContextFactory(IMockContextService mockContextService, ICultureService cultureService, IRequestTraceFactory requestTraceFactory, ITextResource textResource) { _mockContextService = mockContextService; _cultureService = cultureService; _requestTraceFactory = requestTraceFactory; _textResource = textResource; }
/// <summary> /// Creates a new instance of the <see cref="DefaultDiagnostics"/> class. /// </summary> /// <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( 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, INancyEnvironment environment) { 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; this.environment = environment; }
public virtual void Initialize(IScreenGameManager gameManager, ICardsProvider cardsProvider, ITextResource textResource) { SelectedCard = gameManager.Selection.SelectCard(cardsProvider.Cards.OfType <TCard>().ToList()); GameManager = gameManager; TextResource = textResource; Initialize(); }
/// <summary> /// Initializes a new instance of the <see cref="DefaultRenderContext"/> class. /// </summary> /// <param name="viewResolver"></param> /// <param name="viewCache"></param> /// <param name="textResource"></param> /// <param name="viewLocationContext"></param> public DefaultRenderContext(IViewResolver viewResolver, IViewCache viewCache, ITextResource textResource, ViewLocationContext viewLocationContext) { this.viewResolver = viewResolver; this.viewCache = viewCache; this.textResource = textResource; this.viewLocationContext = viewLocationContext; this.textResourceFinder = new TextResourceFinder(textResource, viewLocationContext.Context); }
/// <summary> /// Initializes a new instance of the <see cref="DefaultNancyModuleBuilder"/> class. /// </summary> /// <param name="viewFactory">The <see cref="IViewFactory"/> instance that should be assigned to the module.</param> /// <param name="responseFormatterFactory">An <see cref="IResponseFormatterFactory"/> instance that should be used to create a response formatter for the module.</param> /// <param name="modelBinderLocator">A <see cref="IModelBinderLocator"/> instance that should be assigned to the module.</param> /// <param name="validatorLocator">A <see cref="IModelValidatorLocator"/> instance that should be assigned to the module.</param> public DefaultNancyModuleBuilder(IViewFactory viewFactory, IResponseFormatterFactory responseFormatterFactory, IModelBinderLocator modelBinderLocator, IModelValidatorLocator validatorLocator, ITextResource textResource) { this.viewFactory = viewFactory; this.responseFormatterFactory = responseFormatterFactory; this.modelBinderLocator = modelBinderLocator; this.validatorLocator = validatorLocator; this.textResource = textResource; }
private void InitializeText() { var location = Assembly.GetAssembly(typeof(XmlTextResource)).Location; var path = $@"{Path.GetDirectoryName(location)}\Text.xml"; text = new Text(logger); textResource = new XmlTextResource(path); }
internal XmlPasswordData( PasswordSerializer serializer, ITextResource store ) { if ( serializer == null ) throw new ArgumentNullException( "serializer" ); if ( store == null ) throw new ArgumentNullException( "store" ); _serializer = serializer; _store = store; }
public static ITextResource Create(ITextResource src) { return(new TextResource { Lang = src.Lang, Name = src.Name, Value = src.Value }); }
public ScreenGameManager(DrinctetStatus status, ITextResource textResource) : base(status) { _textResource = textResource; TextDecoder = new DefaultTextDecoder(); TextFormatter = new TextFormatter(Selection, textResource) { BoldPlayerNames = true }; }
public void InitializeFollowUp(IScreenGameManager gameManager, BaseCard card, ITextResource textResource) { SelectedCard = (TCard)card; GameManager = gameManager; TextResource = textResource; var followUp = GameManager.Selection.SelectRandomWeighted(SelectedCard.FollowUp, element => element.Weight); FormatText(followUp); }
/// <summary> /// Initializes a new instance of the <see cref="RazorViewEngine"/> class. /// </summary> /// <param name="configuration">The <see cref="IRazorConfiguration"/> that should be used by the engine.</param> /// <param name="textResource">The <see cref="ITextResource"/> that should be used by the engine.</param> public RazorViewEngine(IRazorConfiguration configuration, ITextResource textResource) { this.viewRenderers = new List <IRazorViewRenderer> { new CSharp.CSharpRazorViewRenderer(), new VisualBasic.VisualBasicRazorViewRenderer() }; this.razorConfiguration = configuration; this.textResource = textResource; }
/// <summary> /// Initializes a new instance of the <see cref="RazorViewEngine"/> class. /// </summary> /// <param name="configuration">The <see cref="IRazorConfiguration"/> that should be used by the engine.</param> /// <param name="textResource">The <see cref="ITextResource"/> that should be used by the engine.</param> public RazorViewEngine(IRazorConfiguration configuration, ITextResource textResource) { this.viewRenderers = new List<IRazorViewRenderer> { new CSharp.CSharpRazorViewRenderer(), new VisualBasic.VisualBasicRazorViewRenderer() }; this.razorConfiguration = configuration; this.textResource = textResource; }
public TestModule(IViewEngine engine, ITextResource textResource) : base("/test") { this.Get ["/{name}/{age}"] = parameters => { ViewBag.Title = "Here is my viewbag title!"; var m = new TestModel(); m.Age = parameters.age; m.Name = parameters.name; return(View["Views/Test/RazorTest", m]); }; }
public TextResourceViewEngineMatcher(ITextResource resource) { this.resource = resource; // This regex will match strings like: // @Text.Resources.Hello_World // @Text.Resources.FooBarBaz; ResourceRegEx = new Regex( @"@Text\.(?<Key>[a-zA-Z0-9-_\.]+);?", RegexOptions.Compiled); }
public DefaultNancyModuleBuilderFixture() { this.module = new FakeNancyModule(); this.responseFormatterFactory = A.Fake<IResponseFormatterFactory>(); this.viewFactory = A.Fake<IViewFactory>(); this.modelBinderLocator = A.Fake<IModelBinderLocator>(); this.validatorLocator = A.Fake<IModelValidatorLocator>(); this.textResource = A.Fake<ITextResource>(); this.builder = new DefaultNancyModuleBuilder(this.viewFactory, this.responseFormatterFactory, this.modelBinderLocator, this.validatorLocator, this.textResource); }
public DefaultNancyModuleBuilderFixture() { this.module = new FakeNancyModule(); this.responseFormatterFactory = A.Fake <IResponseFormatterFactory>(); this.viewFactory = A.Fake <IViewFactory>(); this.modelBinderLocator = A.Fake <IModelBinderLocator>(); this.validatorLocator = A.Fake <IModelValidatorLocator>(); this.textResource = A.Fake <ITextResource>(); this.builder = new DefaultNancyModuleBuilder(this.viewFactory, this.responseFormatterFactory, this.modelBinderLocator, this.validatorLocator, this.textResource); }
public void Initialize(ITextResource resource) { if (resource == null) { throw new ArgumentNullException(nameof(resource)); } try { cache = resource.LoadText() ?? new Dictionary <TextKey, string>(); } catch (Exception e) { logger.Error("Failed to load text data from provided resource!", e); } }
/// <summary> /// Enables the diagnostics dashboard and will intercept all requests that are passed to /// the condigured paths. /// </summary> public static void Enable(IPipelines pipelines, IEnumerable <IDiagnosticsProvider> providers, IRootPathProvider rootPathProvider, IRequestTracing requestTracing, NancyInternalConfiguration configuration, IModelBinderLocator modelBinderLocator, IEnumerable <IResponseProcessor> responseProcessors, IEnumerable <IRouteSegmentConstraint> routeSegmentConstraints, ICultureService cultureService, IRequestTraceFactory requestTraceFactory, IEnumerable <IRouteMetadataProvider> routeMetadataProviders, ITextResource textResource, INancyEnvironment environment, ITypeCatalog typeCatalog, IAssemblyCatalog assemblyCatalog, AcceptHeaderCoercionConventions acceptHeaderCoercionConventions) { var diagnosticsConfiguration = environment.GetValue <DiagnosticsConfiguration>(); var diagnosticsEnvironment = GetDiagnosticsEnvironment(); var diagnosticsModuleCatalog = new DiagnosticsModuleCatalog(providers, rootPathProvider, requestTracing, configuration, diagnosticsEnvironment, typeCatalog, assemblyCatalog); var diagnosticsRouteCache = new RouteCache( diagnosticsModuleCatalog, new DefaultNancyContextFactory(cultureService, requestTraceFactory, textResource, environment), new DefaultRouteSegmentExtractor(), new DefaultRouteDescriptionProvider(), cultureService, routeMetadataProviders); var diagnosticsRouteResolver = new DefaultRouteResolver( diagnosticsModuleCatalog, new DiagnosticsModuleBuilder(rootPathProvider, modelBinderLocator, diagnosticsEnvironment, environment), diagnosticsRouteCache, new RouteResolverTrie(new TrieNodeFactory(routeSegmentConstraints)), environment); var diagnosticResponseNegotiator = new DefaultResponseNegotiator(responseProcessors, acceptHeaderCoercionConventions); var diagnosticRouteInvoker = new DefaultRouteInvoker(diagnosticResponseNegotiator); 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); } if (!diagnosticsConfiguration.Enabled) { return(HttpStatusCode.NotFound); } 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(Path.DirectorySeparatorChar, '.')); } return(new EmbeddedFileResponse( typeof(DiagnosticsHook).GetTypeInfo().Assembly, resourceNamespace, Path.GetFileName(ctx.Request.Url.Path))); } RewriteDiagnosticsUrl(diagnosticsConfiguration, ctx); return(ValidateConfiguration(diagnosticsConfiguration) ? ExecuteDiagnostics(ctx, diagnosticsRouteResolver, diagnosticsConfiguration, serializer, diagnosticsEnvironment, diagnosticRouteInvoker) : new DiagnosticsViewRenderer(ctx, environment)["help"]); })); }
public static IPasswordManagerStorage CreateService( ITextResource passwordsResource ) { return new DefaultPasswordManagerStorage( XmlPasswordData.From( passwordsResource ) ); }
/// <summary> /// Initializes a new instance of the <see cref="DefaultRenderContextFactory"/> class. /// </summary> /// <param name="viewCache">The view cache that should be used by the created render context.</param> /// <param name="viewResolver">The view resolver that should be sused by the created render context.</param> /// <param name="textResource">The <see cref="ITextResource"/> that should be used by the engine.</param> public DefaultRenderContextFactory(IViewCache viewCache, IViewResolver viewResolver, ITextResource textResource) { this.viewCache = viewCache; this.viewResolver = viewResolver; this.textResource = textResource; }
/// <summary> /// Creates a new instance of the <see cref="DefaultNancyContextFactory"/> class. /// </summary> /// <param name="cultureService">An <see cref="ICultureService"/> instance.</param> /// <param name="requestTraceFactory">An <see cref="IRequestTraceFactory"/> instance.</param> /// <param name="textResource">An <see cref="ITextResource"/> instance.</param> public DefaultNancyContextFactory(ICultureService cultureService, IRequestTraceFactory requestTraceFactory, ITextResource textResource) { this.cultureService = cultureService; this.requestTraceFactory = requestTraceFactory; this.textResource = textResource; }
public static IPasswordData From( ITextResource textResource ) { return new XmlPasswordData( new PasswordSerializer( ), textResource ); }
public TextFormatter(ISelectionAlgorithm selection, ITextResource textResource) { _selection = selection; _textResource = textResource; }
public TextResourceFinderFixture() { this.context = A.Dummy<NancyContext>(); this.textResource = A.Fake<ITextResource>(); this.finder = new TextResourceFinder(textResource, context); }
public FindAnchorTags() { _textResource = new TextResource(typeof(FindAnchorTags)); }
public static ISlideViewModel Create(SlideType slideType, ScreenGameManager gameManager, ICardsProvider cardsProvider, ITextResource textResource) { var presenter = GetSlideViewModel(slideType); presenter.Initialize(gameManager, cardsProvider, textResource); return(presenter); }
/// <summary> /// Initializes a new instance of the <see cref="TextResourceFinder"/> class. /// </summary> /// <param name="textResource">The <see cref="ITextResource"/> that should be used by the TextResourceFinder</param> /// <param name="context">The <see cref="NancyContext"/> that should be used by the TextResourceFinder</param> public TextResourceFinder(ITextResource textResource, NancyContext context) { this.textResource = textResource; this.context = context; }
public static void Enable( DiagnosticsConfiguration diagnosticsConfiguration, IPipelines pipelines, IEnumerable <IDiagnosticsProvider> providers, IRootPathProvider rootPathProvider, IRequestTracing requestTracing, NancyInternalConfiguration configuration, IModelBinderLocator modelBinderLocator, IEnumerable <IResponseProcessor> responseProcessors, IEnumerable <IRouteSegmentConstraint> routeSegmentConstraints, ICultureService cultureService, IRequestTraceFactory requestTraceFactory, IEnumerable <IRouteMetadataProvider> routeMetadataProviders, ITextResource textResource) { var diagnosticsModuleCatalog = new DiagnosticsModuleCatalog(providers, rootPathProvider, requestTracing, configuration, diagnosticsConfiguration); var diagnosticsRouteCache = new RouteCache( diagnosticsModuleCatalog, new DefaultNancyContextFactory(cultureService, requestTraceFactory, textResource), new DefaultRouteSegmentExtractor(), new DefaultRouteDescriptionProvider(), cultureService, routeMetadataProviders); var diagnosticsRouteResolver = new DefaultRouteResolver( diagnosticsModuleCatalog, new DiagnosticsModuleBuilder(rootPathProvider, modelBinderLocator), diagnosticsRouteCache, new RouteResolverTrie(new TrieNodeFactory(routeSegmentConstraints))); 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(Path.DirectorySeparatorChar, '.')); } 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)); })); }
public TextResourceServiceTest() { _service = new TextResource(typeof(TextResourceServiceTest)); }
public I18nOperation(ILogger logger, IText text, ITextResource textResource) { this.logger = logger; this.text = text; this.textResource = textResource; }
public TextResourceFinderFixture() { this.context = A.Dummy <NancyContext>(); this.textResource = A.Fake <ITextResource>(); this.finder = new TextResourceFinder(textResource, context); }
public DynamicMemberChainer(string memberName, NancyContext context, ITextResource resource) { this.memberName = memberName; this.context = context; this.textResource = resource; }
public static void Enable( DiagnosticsConfiguration diagnosticsConfiguration, IPipelines pipelines, IEnumerable<IDiagnosticsProvider> providers, IRootPathProvider rootPathProvider, IRequestTracing requestTracing, NancyInternalConfiguration configuration, IModelBinderLocator modelBinderLocator, IEnumerable<IResponseProcessor> responseProcessors, IEnumerable<IRouteSegmentConstraint> routeSegmentConstraints, ICultureService cultureService, IRequestTraceFactory requestTraceFactory, IEnumerable<IRouteMetadataProvider> routeMetadataProviders, ITextResource textResource) { var diagnosticsModuleCatalog = new DiagnosticsModuleCatalog(providers, rootPathProvider, requestTracing, configuration, diagnosticsConfiguration); var diagnosticsRouteCache = new RouteCache( diagnosticsModuleCatalog, new DefaultNancyContextFactory(cultureService, requestTraceFactory, textResource), new DefaultRouteSegmentExtractor(), new DefaultRouteDescriptionProvider(), cultureService, routeMetadataProviders); var diagnosticsRouteResolver = new DefaultRouteResolver( diagnosticsModuleCatalog, new DiagnosticsModuleBuilder(rootPathProvider, modelBinderLocator), diagnosticsRouteCache, new RouteResolverTrie(new TrieNodeFactory(routeSegmentConstraints))); 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(Path.DirectorySeparatorChar, '.')); } 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); })); }