public DebugHtmlPage(
     IHtmlWriterFactory htmlWriterFactory,
     IRenderContextFactory renderContextFactory)
 {
     _htmlWriterFactory    = htmlWriterFactory;
     _renderContextFactory = renderContextFactory;
 }
 public PageDependenciesFactory(
     IRenderContextFactory renderContextFactory,
     IIdManager idManager,
     IAssetManager assetManager,
     INameManager nameManager,
     ICssWriterFactory cssWriterFactory,
     IJavascriptWriterFactory javascriptWriterFactory,
     IDataScopeProviderFactory dataScopeProviderFactory,
     IDataConsumerFactory dataConsumerFactory,
     IDictionaryFactory dictionaryFactory,
     IDataContextBuilderFactory dataContextBuilderFactory,
     IDataCatalog dataCatalog,
     IDataDependencyFactory dataDependencyFactory)
 {
     _renderContextFactory      = renderContextFactory;
     _idManager                 = idManager;
     _assetManager              = assetManager;
     _nameManager               = nameManager;
     _cssWriterFactory          = cssWriterFactory;
     _javascriptWriterFactory   = javascriptWriterFactory;
     _dataScopeProviderFactory  = dataScopeProviderFactory;
     _dataConsumerFactory       = dataConsumerFactory;
     _dictionaryFactory         = dictionaryFactory;
     _dataContextBuilderFactory = dataContextBuilderFactory;
     _dataCatalog               = dataCatalog;
     _dataDependencyFactory     = dataDependencyFactory;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultViewFactory"/> class.
        /// </summary>
        /// <param name="viewResolver">An <see cref="IViewResolver"/> instance that should be used to resolve the location of a view.</param>
        /// <param name="viewEngines">An <see cref="IEnumerable{T}"/> instance containing the <see cref="IViewEngine"/> instances that should be able to be used to render a view</param>
        /// <param name="renderContextFactory">A <see cref="IRenderContextFactory"/> instance that should be used to create an <see cref="IRenderContext"/> when a view is rendered.</param>
        public DefaultViewFactory(IViewResolver viewResolver, IEnumerable <IViewEngine> viewEngines, IRenderContextFactory renderContextFactory)
        {
            this.viewResolver         = viewResolver;
            this.viewEngines          = viewEngines;
            this.renderContextFactory = renderContextFactory;

            this.viewEngineExtensions = this.viewEngines.SelectMany(ive => ive.Extensions).ToArray();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultViewFactory"/> class.
        /// </summary>
        /// <param name="viewResolver">An <see cref="IViewResolver"/> instance that should be used to resolve the location of a view.</param>
        /// <param name="viewEngines">An <see cref="IEnumerable{T}"/> instance containing the <see cref="IViewEngine"/> instances that should be able to be used to render a view</param>
        /// <param name="renderContextFactory">A <see cref="IRenderContextFactory"/> instance that should be used to create an <see cref="IRenderContext"/> when a view is rendered.</param>
        public DefaultViewFactory(IViewResolver viewResolver, IEnumerable<IViewEngine> viewEngines, IRenderContextFactory renderContextFactory)
        {
            this.viewResolver = viewResolver;
            this.viewEngines = viewEngines;
            this.renderContextFactory = renderContextFactory;

            this.viewEngineExtensions = this.viewEngines.SelectMany(ive => ive.Extensions).ToArray();
        }
Ejemplo n.º 5
0
 public ServiceDependenciesFactory(
     IRenderContextFactory renderContextFactory,
     IAssetManager assetManager,
     INameManager nameManager)
 {
     _renderContextFactory = renderContextFactory;
     AssetManager          = assetManager;
     NameManager           = nameManager;
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultViewFactory"/> class.
        /// </summary>
        /// <param name="viewResolver">An <see cref="IViewResolver"/> instance that should be used to resolve the location of a view.</param>
        /// <param name="viewEngines">An <see cref="IEnumerable{T}"/> instance containing the <see cref="IViewEngine"/> instances that should be able to be used to render a view</param>
        /// <param name="renderContextFactory">A <see cref="IRenderContextFactory"/> instance that should be used to create an <see cref="IRenderContext"/> when a view is rendered.</param>
        /// <param name="conventions">An <see cref="ViewLocationConventions"/> instance that should be used to resolve all possible view locations </param>
        /// <param name="rootPathProvider">An <see cref="IRootPathProvider"/> instance.</param>
        public DefaultViewFactory(IViewResolver viewResolver, IEnumerable <IViewEngine> viewEngines, IRenderContextFactory renderContextFactory, ViewLocationConventions conventions, IRootPathProvider rootPathProvider)
        {
            this.viewResolver         = viewResolver;
            this.viewEngines          = viewEngines;
            this.renderContextFactory = renderContextFactory;
            this.conventions          = conventions;
            this.rootPathProvider     = rootPathProvider;

            this.viewEngineExtensions = this.viewEngines.SelectMany(ive => ive.Extensions).ToArray();
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultViewFactory"/> class.
        /// </summary>
        /// <param name="viewResolver">An <see cref="IViewResolver"/> instance that should be used to resolve the location of a view.</param>
        /// <param name="viewEngines">An <see cref="IEnumerable{T}"/> instance containing the <see cref="IViewEngine"/> instances that should be able to be used to render a view</param>
        /// <param name="renderContextFactory">A <see cref="IRenderContextFactory"/> instance that should be used to create an <see cref="IRenderContext"/> when a view is rendered.</param>
        /// <param name="conventions">An <see cref="ViewLocationConventions"/> instance that should be used to resolve all possible view locations </param>
        /// <param name="rootPathProvider">An <see cref="IRootPathProvider"/> instance.</param>
        public DefaultViewFactory(IViewResolver viewResolver, IEnumerable<IViewEngine> viewEngines, IRenderContextFactory renderContextFactory, ViewLocationConventions conventions, IRootPathProvider rootPathProvider)
        {
            this.viewResolver = viewResolver;
            this.viewEngines = viewEngines;
            this.renderContextFactory = renderContextFactory;
            this.conventions = conventions;
            this.rootPathProvider = rootPathProvider;

            this.viewEngineExtensions = this.viewEngines.SelectMany(ive => ive.Extensions).ToArray();
        }
 public DebugInfoMiddleware(
     IRequestRouter requestRouter,
     IHtmlWriterFactory htmlWriterFactory,
     IRenderContextFactory renderContextFactory)
 {
     _requestRouter        = requestRouter;
     _htmlWriterFactory    = htmlWriterFactory;
     _renderContextFactory = renderContextFactory;
     this.RunFirst();
 }
Ejemplo n.º 9
0
        public DefaultViewFactoryFixture()
        {
            this.resolver             = A.Fake <IViewResolver>();
            this.renderContextFactory = A.Fake <IRenderContextFactory>();

            this.viewLocationContext =
                new ViewLocationContext
            {
                Context = new NancyContext()
            };
        }
Ejemplo n.º 10
0
        public DefaultViewFactoryFixture()
        {
            this.resolver = A.Fake<IViewResolver>();
            this.renderContextFactory = A.Fake<IRenderContextFactory>();

            this.viewLocationContext =
                new ViewLocationContext
                {
                    Context = new NancyContext()
                };
        }
        public DefaultViewFactoryFixture()
        {
            this.resolver = A.Fake<IViewResolver>();
            this.renderContextFactory = A.Fake<IRenderContextFactory>();
            this.conventions = new ViewLocationConventions(Enumerable.Empty<Func<string, object, ViewLocationContext, string>>());

            this.viewLocationContext =
                new ViewLocationContext
                {
                    Context = new NancyContext()
                };
        }
Ejemplo n.º 12
0
        public GetRecsModule(IConfig config, IMyAnimeListApiFactory malApiFactory, IAnimeRecsClientFactory recClientFactory, IAnimeRecsDbConnectionFactory dbConnectionFactory, IViewFactory viewFactory, IViewLocator viewLocator, RazorViewEngine viewEngine, IRenderContextFactory renderContextFactory)
        {
            _config = config;
            _malApiFactory = malApiFactory;
            _recClientFactory = recClientFactory;
            _dbConnectionFactory = dbConnectionFactory;
            _viewLocator = viewLocator;
            _viewEngine = viewEngine;
            _renderContextFactory = renderContextFactory;

            Post["/GetRecs"] = GetRecs;
        }
Ejemplo n.º 13
0
        public DefaultViewFactoryFixture()
        {
            this.rootPathProvider = A.Fake <IRootPathProvider>();
            A.CallTo(() => this.rootPathProvider.GetRootPath()).Returns("The root path");

            this.resolver             = A.Fake <IViewResolver>();
            this.renderContextFactory = A.Fake <IRenderContextFactory>();
            this.conventions          = new ViewLocationConventions(Enumerable.Empty <Func <string, object, ViewLocationContext, string> >());

            this.viewLocationContext =
                new ViewLocationContext
            {
                Context = new NancyContext()
            };
        }
Ejemplo n.º 14
0
 public ServiceDependenciesFactory(
     IRenderContextFactory renderContextFactory,
     IAssetManager assetManager,
     INameManager nameManager,
     IRequestRouter requestRouter,
     IDataCatalog dataCatalog,
     IDataDependencyFactory dataDependencyFactory)
 {
     _renderContextFactory = renderContextFactory;
     AssetManager          = assetManager;
     NameManager           = nameManager;
     RequestRouter         = requestRouter;
     DataCatalog           = dataCatalog;
     DataDependencyFactory = dataDependencyFactory;
 }
Ejemplo n.º 15
0
        public DefaultViewFactoryFixture()
        {
            this.rootPathProvider = A.Fake<IRootPathProvider>();
            A.CallTo(() => this.rootPathProvider.GetRootPath()).Returns("The root path");

            this.resolver = A.Fake<IViewResolver>();
            this.renderContextFactory = A.Fake<IRenderContextFactory>();
            this.conventions = new ViewLocationConventions(Enumerable.Empty<Func<string, object, ViewLocationContext, string>>());

            this.viewLocationContext =
                new ViewLocationContext
                {
                    Context = new NancyContext()
                };
        }
Ejemplo n.º 16
0
        internal static void Run(IRenderContextFactory factory, Assembly asm)
        {
            TypeInfo[] types = asm.ExportedTypes.Select(t => t.GetTypeInfo()).Where(t => t.GetCustomAttribute <ApplicationAttribute>() != null).ToArray();
            switch (types.Length)
            {
            case 0:
                Console.Error.WriteLine("Please annotate a class with [Application].");
                Environment.Exit(1);
                break;

            case 1:
                object appObj = types[0].GetConstructor(new Type[0]).Invoke(new object[0]);
                if (!(appObj is IApplication))
                {
                    Console.WriteLine("Application needs to be upgraded");
                }
                if (appObj is IApplication)
                {
                    IApplication    app  = (IApplication)appObj;
                    ApplicationType type = app.Type;
                    if (factory.SupportsApplication(type))
                    {
                        IRenderContext ctx = factory.CreateContext(type, app.Name);
                        app.Start(ctx);
                        ctx.ShuttingDown += app.Stop;
                        if (ctx is IRenderContextInternal)
                        {
                            ((IRenderContextInternal)ctx).Start();
                        }
                    }
                    else
                    {
                        Console.Error.WriteLine("Unable to create render context for application because it is not supported on this platform.");
                    }
                }
                break;

            default:
                Console.Error.WriteLine("Please only annotate one class with [Application].");
                Environment.Exit(1);
                break;
            }
        }
 public PackageDependenciesFactory(
     IRenderContextFactory renderContextFactory,
     IDataContextFactory dataContextFactory,
     IAssetManager assetManager,
     INameManager nameManager,
     IModuleDependenciesFactory moduleDependenciesFactory,
     IPageDependenciesFactory pageDependenciesFactory,
     ILayoutDependenciesFactory layoutDependenciesFactory,
     IRegionDependenciesFactory regionDependenciesFactory,
     IComponentDependenciesFactory componentDependenciesFactory,
     IDataProviderDependenciesFactory dataProviderDependenciesFactory)
 {
     _renderContextFactory            = renderContextFactory;
     _dataContextFactory              = dataContextFactory;
     _assetManager                    = assetManager;
     _nameManager                     = nameManager;
     _moduleDependenciesFactory       = moduleDependenciesFactory;
     _pageDependenciesFactory         = pageDependenciesFactory;
     _layoutDependenciesFactory       = layoutDependenciesFactory;
     _regionDependenciesFactory       = regionDependenciesFactory;
     _componentDependenciesFactory    = componentDependenciesFactory;
     _dataProviderDependenciesFactory = dataProviderDependenciesFactory;
 }
Ejemplo n.º 18
0
 public ConfigurableModelViewFactory(IViewResolver viewResolver, IEnumerable <IViewEngine> viewEngines, IRenderContextFactory renderContextFactory)
 {
     _viewFactory = new DefaultViewFactory(viewResolver, viewEngines, renderContextFactory);
 }
Ejemplo n.º 19
0
 public DefaultViewFactoryFixture()
 {
     this.resolver             = A.Fake <IViewResolver>();
     this.renderContextFactory = A.Fake <IRenderContextFactory>();
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultViewFactory"/> class.
 /// </summary>
 /// <param name="viewResolver">An <see cref="IViewResolver"/> instance that should be used to resolve the location of a view.</param>
 /// <param name="viewEngines">An <see cref="IEnumerable{T}"/> instance containing the <see cref="IViewEngine"/> instances that should be able to be used to render a view</param>
 /// <param name="renderContextFactory">A <see cref="IRenderContextFactory"/> instance that should be used to create an <see cref="IRenderContext"/> when a view is rendered.</param>
 public DefaultViewFactory(IViewResolver viewResolver, IEnumerable<IViewEngine> viewEngines, IRenderContextFactory renderContextFactory)
 {
     this.viewResolver = viewResolver;
     this.viewEngines = viewEngines;
     this.renderContextFactory = renderContextFactory;
 }
Ejemplo n.º 21
0
 public RazorPreloader(RazorViewEngine engine, IViewLocator viewLocator, IRenderContextFactory renderContextFactory)
 {
     _engine = engine;
     _viewLocator = viewLocator;
     _renderContextFactory = renderContextFactory;
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultViewFactory"/> class.
 /// </summary>
 /// <param name="viewResolver">An <see cref="IViewResolver"/> instance that should be used to resolve the location of a view.</param>
 /// <param name="viewEngines">An <see cref="IEnumerable{T}"/> instance containing the <see cref="IViewEngine"/> instances that should be able to be used to render a view</param>
 /// <param name="renderContextFactory">A <see cref="IRenderContextFactory"/> instance that should be used to create an <see cref="IRenderContext"/> when a view is rendered.</param>
 public DefaultViewFactory(IViewResolver viewResolver, IEnumerable <IViewEngine> viewEngines, IRenderContextFactory renderContextFactory)
 {
     this.viewResolver         = viewResolver;
     this.viewEngines          = viewEngines;
     this.renderContextFactory = renderContextFactory;
 }
Ejemplo n.º 23
0
        private static void PrecompileView(string viewPath, object viewModel, RazorViewEngine engine, IViewLocator locator,
            IRenderContextFactory renderContextFactory, RazorPreloader preloader)
        {
            try
            {
                Logging.Log.DebugFormat("Precompiling view {0}", viewPath);
                preloader.PreloadRazorView(viewPath, viewModel);
                Logging.Log.DebugFormat("Finished precompiling view {0}", viewPath);
            }
            catch (Exception ex)
            {
                Logging.Log.ErrorFormat("Error precompiling view {0}: {1}", ex, viewPath, ex.Message);
            }

            lock (ViewsFinishedPrecompiling)
            {
                ViewsFinishedPrecompiling.Add(viewPath);
                if (ViewsFinishedPrecompiling.Count == ViewPathsAndModels.Count)
                {
                    Logging.Log.Info("Finished precompiling views");
                }
            }
        }
Ejemplo n.º 24
0
 public DefaultViewFactoryFixture()
 {
     this.resolver = A.Fake<IViewResolver>();
     this.renderContextFactory = A.Fake<IRenderContextFactory>();
 }
 public ConfigurableModelViewFactory(IViewResolver viewResolver, IEnumerable<IViewEngine> viewEngines, IRenderContextFactory renderContextFactory)
 {
     _viewFactory = new DefaultViewFactory(viewResolver, viewEngines, renderContextFactory);
 }