Esempio n. 1
0
        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());
        }
Esempio n. 2
0
        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());
        }
Esempio n. 3
0
 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;
 }
Esempio n. 4
0
 /// <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="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 PactAwareContextFactory(IMockContextService mockContextService, ICultureService cultureService, IRequestTraceFactory requestTraceFactory, ITextResource textResource)
 {
     _mockContextService = mockContextService;
     _cultureService = cultureService;
     _requestTraceFactory = requestTraceFactory;
     _textResource = textResource;
 }
Esempio n. 10
0
 /// <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;
 }
Esempio n. 11
0
        public virtual void Initialize(IScreenGameManager gameManager, ICardsProvider cardsProvider, ITextResource textResource)
        {
            SelectedCard = gameManager.Selection.SelectCard(cardsProvider.Cards.OfType <TCard>().ToList());
            GameManager  = gameManager;
            TextResource = textResource;

            Initialize();
        }
Esempio n. 12
0
 /// <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;
 }
Esempio n. 14
0
 /// <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;
 }
 /// <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);
 }
        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;
 }
Esempio n. 18
0
 public static ITextResource Create(ITextResource src)
 {
     return(new TextResource
     {
         Lang = src.Lang,
         Name = src.Name,
         Value = src.Value
     });
 }
Esempio n. 19
0
 public ScreenGameManager(DrinctetStatus status, ITextResource textResource) : base(status)
 {
     _textResource = textResource;
     TextDecoder   = new DefaultTextDecoder();
     TextFormatter = new TextFormatter(Selection, textResource)
     {
         BoldPlayerNames = true
     };
 }
Esempio n. 20
0
        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);
        }
Esempio n. 21
0
        /// <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;
        }
Esempio n. 22
0
        /// <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;
        }
Esempio n. 23
0
 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]);
     };
 }
Esempio n. 24
0
        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);
        }
Esempio n. 27
0
        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);
            }
        }
Esempio n. 28
0
        /// <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;
 }
Esempio n. 31
0
 /// <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 );
 }
Esempio n. 33
0
 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);
 }
 /// <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;
 }
Esempio n. 36
0
 public FindAnchorTags()
 {
     _textResource = new TextResource(typeof(FindAnchorTags));
 }
Esempio n. 37
0
        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="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>
 /// 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));
            }));
        }
Esempio n. 41
0
 public TextResourceServiceTest()
 {
     _service = new TextResource(typeof(TextResourceServiceTest));
 }
 public I18nOperation(ILogger logger, IText text, ITextResource textResource)
 {
     this.logger       = logger;
     this.text         = text;
     this.textResource = textResource;
 }
Esempio n. 43
0
 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;
 }
Esempio n. 45
0
 /// <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;
 }
Esempio n. 46
0
        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);
                    }));
        }
Esempio n. 47
0
 public DynamicMemberChainer(string memberName, NancyContext context, ITextResource resource)
 {
     this.memberName = memberName;
     this.context = context;
     this.textResource = resource;
 }