public RazorViewToStringRenderer(IRazorViewEngine viewEngine, ITempDataProvider tempDataProvider,
     IServiceProvider serviceProvider)
 {
     _viewEngine = viewEngine;
     _tempDataProvider = tempDataProvider;
     _serviceProvider = serviceProvider;
 }
Exemplo n.º 2
0
 public HtmlEngineFactory(IHttpContextAccessor httpContextAccessor, ICompositeViewEngine viewEngine, ITempDataProvider tempDataProvider, IApplicationEnvironment hostingEnvironment)
 {
     _httpContextAccessor = httpContextAccessor;
     _viewEngine = viewEngine;
     _tempDataProvider = tempDataProvider;
     _hostingEnvironment = hostingEnvironment;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BlogController" /> class.
 /// </summary>
 /// <param name="blogRepository">The blog repository.</param>
 /// <param name="tempDataProvider">The temporary data provider</param>
 /// <param name="webCache">Web cache to clear when modifying posts</param>
 /// <param name="comments">Disqus comments service</param>
 public BlogController(IBlogRepository blogRepository, ITempDataProvider tempDataProvider, IWebCache webCache, IDisqusComments comments)
 {
     _blogRepository = blogRepository;
     _webCache = webCache;
     _comments = comments;
     // TODO: This shouldn't be required to be passed in the constructor - Can set it as a property.
     TempDataProvider = tempDataProvider;
 }
Exemplo n.º 4
0
        /// <summary>
        /// 加载数据
        /// </summary>
        /// <param name="controllerContext"></param>
        /// <param name="tempDataProvider"></param>
        public void Load(ControllerContext controllerContext, ITempDataProvider tempDataProvider)
        {
            IDictionary <string, object> dictionary = tempDataProvider.LoadTempData(controllerContext);

            this._data        = ((dictionary != null) ? new Dictionary <string, object>(dictionary, StringComparer.OrdinalIgnoreCase) : new Dictionary <string, object>(StringComparer.OrdinalIgnoreCase));
            this._initialKeys = new HashSet <string>(this._data.Keys, StringComparer.OrdinalIgnoreCase);
            this._retainedKeys.Clear();
        }
Exemplo n.º 5
0
 public ViewRenderService(IRazorViewEngine razorViewEngine, ITempDataProvider tempDataProvider,
                          IServiceProvider serviceProvider, IHttpContextAccessor accessor)
 {
     this.razorViewEngine  = razorViewEngine;
     this.tempDataProvider = tempDataProvider;
     this.serviceProvider  = serviceProvider;
     this.context          = accessor.HttpContext;
 }
Exemplo n.º 6
0
 public ProviderAccountHandler(IHostingEnvironment hostingEnvironment, IProviderVacancyClient client, IRecruitVacancyClient vacancyClient, IBlockedOrganisationQuery blockedOrganisationsRepo, ITempDataProvider tempDataProvider)
 {
     _hostingEnvironment       = hostingEnvironment;
     _client                   = client;
     _vacancyClient            = vacancyClient;
     _blockedOrganisationsRepo = blockedOrganisationsRepo;
     _tempDataProvider         = tempDataProvider;
 }
Exemplo n.º 7
0
 public NccRazorViewRenderService(IRazorViewEngine razorViewEngine, ITempDataProvider tempDataProvider, IServiceProvider serviceProvider, IHttpContextAccessor httpContextAccessor, ILoggerFactory loggerFactory)
 {
     _razorViewEngine     = razorViewEngine;
     _tempDataProvider    = tempDataProvider;
     _serviceProvider     = serviceProvider;
     _httpContextAccessor = httpContextAccessor;
     _logger = loggerFactory.CreateLogger <NccRazorViewRenderService>();
 }
Exemplo n.º 8
0
 public TemplateService(IRazorViewEngine razorViewEngine,
                        ITempDataProvider tempDataProvider,
                        IServiceProvider serviceProvider)
 {
     this.razorViewEngine  = razorViewEngine;
     this.tempDataProvider = tempDataProvider;
     this.serviceProvider  = serviceProvider;
 }
Exemplo n.º 9
0
 public ViewRenderService(string rootPath, IRazorViewEngine viewEngine, IHttpContextAccessor httpContextAccessor, ITempDataProvider tempDataProvider, IServiceProvider serviceProvider)
 {
     this.rootPath            = rootPath;
     this.viewEngine          = viewEngine;
     this.httpContextAccessor = httpContextAccessor;
     this.tempDataProvider    = tempDataProvider ?? this;
     this.serviceProvider     = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider));
 }
Exemplo n.º 10
0
 public RenderViewAsString(IRazorViewEngine razorViewEngine,
                           ITempDataProvider tempDataProvider,
                           IServiceProvider serviceProvider)
 {
     _razorViewEngine  = razorViewEngine;
     _tempDataProvider = tempDataProvider;
     _serviceProvider  = serviceProvider;
 }
Exemplo n.º 11
0
 public ViewRender(IRazorViewEngine viewEngine,
                   ITempDataProvider tempDataProvider,
                   IServiceProvider serviceProvider)
 {
     _viewEngine       = viewEngine;
     _tempDataProvider = tempDataProvider;
     _serviceProvider  = serviceProvider;
 }
Exemplo n.º 12
0
 public ViewRenderService(IRazorViewEngine razorViewEngine,
                          ITempDataProvider tempDataProvider,
                          IServiceProvider serviceProvider)
 {
     _razorViewEngine  = razorViewEngine;
     _tempDataProvider = tempDataProvider;
     _serviceProvider  = serviceProvider;
 }
 /// <summary>
 /// Initializes a new RazorContentRenderer.
 /// </summary>
 /// <param name="razorViewEngine">The razor view engine used to locate the view.</param>
 /// <param name="tempDataProvider">Tempdata provider used in the view context of the view.</param>
 /// <param name="serviceProvider">The service provider used to create an http context.</param>
 public RazorContentRenderer(IRazorViewEngine razorViewEngine,
                             ITempDataProvider tempDataProvider,
                             IServiceProvider serviceProvider)
 {
     _razorViewEngine  = razorViewEngine;
     _tempDataProvider = tempDataProvider;
     _serviceProvider  = serviceProvider;
 }
Exemplo n.º 14
0
 public RazorViewRenderer(
     IRazorViewEngine razorViewEngine,
     ITempDataProvider tempDataProvider
     )
 {
     _razorViewEngine  = razorViewEngine;
     _tempDataProvider = tempDataProvider;
 }
Exemplo n.º 15
0
        public static async Task <string> RenderView(string path, ViewDataDictionary viewDataDictionary)
        {
            if (ServiceProvider == null)
            {
                throw new InvalidOperationException($"In order to use the facade, {nameof(UseMailTemplates)} must be called in Startup.Configure method. ");
            }

            path = path ?? throw new ArgumentNullException(nameof(path));
            viewDataDictionary = viewDataDictionary ?? throw new ArgumentNullException(nameof(viewDataDictionary));

            path = path.EndsWith(".cshtml") ? path : $"{path}.cshtml";
            path = path.Trim('/');

            using (IServiceScope scope = ServiceProvider.CreateScope())
            {
                MailOptions          options             = scope.ServiceProvider.GetRequiredService <IOptions <MailOptions> >().Value;
                ICompositeViewEngine viewEngine          = scope.ServiceProvider.GetRequiredService <ICompositeViewEngine>();
                ITempDataProvider    tempDataProvider    = scope.ServiceProvider.GetRequiredService <ITempDataProvider>();
                IHttpContextAccessor httpContextAccessor = scope.ServiceProvider.GetRequiredService <IHttpContextAccessor>();
                HttpContext          httpContext         = httpContextAccessor.HttpContext;
                if (httpContext == null)
                {
                    httpContext = new DefaultHttpContext
                    {
                        RequestServices = scope.ServiceProvider
                    };
                }
                ActionContext actionContext = new ActionContext(httpContext, new RouteData(), new ActionDescriptor());
                viewDataDictionary.Model = null;

                using (StringWriter sw = new StringWriter())
                {
                    ViewEngineResult viewResult = viewEngine.GetView($"{options.ViewTemplateBasePath}/{path}", $"{options.ViewTemplateBasePath}/{path}", true);

                    if (viewResult?.View == null)
                    {
                        throw new Exception($"View {options.ViewTemplateBasePath}/{path} not found.");
                    }

                    ViewContext viewContext = new ViewContext(actionContext, viewResult.View, viewDataDictionary, new TempDataDictionary(httpContext, tempDataProvider), sw, new HtmlHelperOptions());

                    await viewResult.View.RenderAsync(viewContext);

                    sw.Flush();

                    if (viewContext.ViewData != viewDataDictionary)
                    {
                        var keys = viewContext.ViewData.Keys.ToArray();
                        foreach (var key in keys)
                        {
                            viewDataDictionary[key] = viewContext.ViewData[key];
                        }
                    }

                    return(sw.ToString());
                }
            }
        }
Exemplo n.º 16
0
 public ViewRenderer(
     ICompositeViewEngine viewEngine,
     ITempDataProvider tempDataProvider,
     IHttpContextAccessor contextAccesor)
 {
     this.viewEngine       = viewEngine;
     this.tempDataProvider = tempDataProvider;
     this.contextAccesor   = contextAccesor;
 }
 public TemplateService(
     IRazorViewEngine engine,
     IServiceProvider serviceProvider,
     ITempDataProvider tempDataProvider)
 {
     this._razorViewEngine  = engine;
     this._serviceProvider  = serviceProvider;
     this._tempDataProvider = tempDataProvider;
 }
Exemplo n.º 18
0
        public void Load(ControllerContext controllerContext, ITempDataProvider tempDataProvider)
        {
            IDictionary <string, object> providerDictionary = tempDataProvider.LoadTempData(controllerContext);

            _data = (providerDictionary != null) ? new Dictionary <string, object>(providerDictionary, StringComparer.OrdinalIgnoreCase) :
                    new Dictionary <string, object>(StringComparer.OrdinalIgnoreCase);
            _initialKeys = new HashSet <string>(_data.Keys);
            _modifiedKeys.Clear();
        }
        /// <summary>
        /// CTOR
        /// </summary>
        /// <param name="logger"></param>
        /// <param name="accessor"></param>
        /// <param name="razorViewEngine"></param>
        /// <param name="tempDataProvider"></param>

        public ViewRenderService(ILogger <ViewRenderService> logger, IHttpContextAccessor accessor,
                                 IRazorViewEngine razorViewEngine, ITempDataProvider tempDataProvider, IServiceProvider serviceProvider)
        {
            _logger           = logger;
            _accessor         = accessor;
            _razorViewEngine  = razorViewEngine;
            _tempDataProvider = tempDataProvider;
            _serviceProvider  = serviceProvider;
        }
 public RazorViewStringRenderer(
     IRazorViewEngine viewEngine,
     ITempDataProvider tempDataProvider,
     IViewRendererActionContextFactory viewRendererFactory)
 {
     this.viewEngine          = viewEngine;
     this.tempDataProvider    = tempDataProvider;
     this.viewRendererFactory = viewRendererFactory;
 }
Exemplo n.º 21
0
 public ViewComponentManager(IViewComponentSelector viewComponentSelector, IViewComponentHelper viewComponentHelper, IActionContextAccessor actionContextAccessor, IViewAccountant viewAccountant, ITempDataProvider tempDataProvider, ILocalFileProvider localFileProvider)
 {
     _viewComponentSelector = viewComponentSelector;
     _viewComponentHelper   = viewComponentHelper;
     _actionContextAccessor = actionContextAccessor;
     _viewAccountant        = viewAccountant;
     _tempDataProvider      = tempDataProvider;
     _localFileProvider     = localFileProvider;
 }
 public RazorPartialToStringRenderer(
     IRazorViewEngine viewEngine,
     ITempDataProvider tempDataProvider,
     IServiceProvider serviceProvider)
 {
     _viewEngine       = viewEngine;
     _tempDataProvider = tempDataProvider;
     _serviceProvider  = serviceProvider;
 }
        /// <summary>
        /// Initialices the service instances
        /// </summary>
        /// <param name="viewEngine">The razor engine to be used by render the views</param>
        /// <param name="httpContextAccessor"><see cref="IHttpContextAccessor"/> instance use of
        /// access to the current HTTP context</param>
        /// <param name="tempDataProvider">The <see cref="ITempDataProvider"/> used to Load
        /// and Save data</param>
        /// <param name="serviceProvider">Instance of <see cref="IServiceProvider" /> used of access
        /// to the configured services into the startup class</param>
        /// <param name="metadataProvider"><see cref="IModelMetadataProvider"/> instance used to
        /// create <see cref="ModelExplorer"/> instances</param>
        /// <param name="actionContextAccessor"><see cref="IActionContextAccessor"/> instance used
        /// to located the required views</param>
        /// <param name="environmet"><see cref="IHostingEnvironment"/> instance used to located
        /// the web root path</param>
        public ViewRenderService(
            IRazorViewEngine viewEngine,
            IHttpContextAccessor httpContextAccessor,
            ITempDataProvider tempDataProvider,
            IServiceProvider serviceProvider,
            IModelMetadataProvider metadataProvider,
            IActionContextAccessor actionContextAccessor,
#if NETCOREAPP2_1
            IHostingEnvironment environmet
Exemplo n.º 24
0
 public TemplateHelper(
     IRazorViewEngine engine,
     IServiceProvider serviceProvider,
     ITempDataProvider tempDataProvider)
 {
     _razorViewEngine  = engine;
     _serviceProvider  = serviceProvider;
     _tempDataProvider = tempDataProvider;
 }
Exemplo n.º 25
0
 public EmailTemplateService(
     IRazorViewEngine razorViewEngine,
     ITempDataProvider tempDataProvider,
     IServiceProvider serviceProvider)
 {
     _razorViewEngine  = razorViewEngine;
     _tempDataProvider = tempDataProvider;
     _serviceProvider  = serviceProvider;
 }
Exemplo n.º 26
0
 public CPS8xCodeGeneratorService(
     IRazorViewEngine razorViewEngine,
     ITempDataProvider tempDataProvider,
     IServiceProvider serviceProvider)
 {
     this.razorViewEngine  = razorViewEngine;
     this.tempDataProvider = tempDataProvider;
     this.serviceProvider  = serviceProvider;
 }
Exemplo n.º 27
0
 public ViewRenderService(IRazorViewEngine razorViewEngine,
                          ITempDataProvider tempDataProvider,
                          IServiceProvider serviceProvider, IHttpContextAccessor accessor)
 {
     _razorViewEngine  = razorViewEngine;
     _tempDataProvider = tempDataProvider;
     _serviceProvider  = serviceProvider;
     httpContext       = accessor.HttpContext;
 }
Exemplo n.º 28
0
 public RazorViewToStringRenderer(
     IOptions <MvcViewOptions> options,
     ITempDataProvider tempDataProvider,
     IServiceProvider serviceProvider)
 {
     _options          = options;
     _tempDataProvider = tempDataProvider;
     _serviceProvider  = serviceProvider;
 }
Exemplo n.º 29
0
    /// <summary>
    /// Creates a new <see cref="TempDataDictionaryFactory"/>.
    /// </summary>
    /// <param name="provider">The <see cref="ITempDataProvider"/>.</param>
    public TempDataDictionaryFactory(ITempDataProvider provider)
    {
        if (provider == null)
        {
            throw new ArgumentNullException(nameof(provider));
        }

        _provider = provider;
    }
        /// <summary>
        /// Creates a new <see cref="TempDataDictionaryFactory"/>.
        /// </summary>
        /// <param name="provider">The <see cref="ITempDataProvider"/>.</param>
        public TempDataDictionaryFactory(ITempDataProvider provider)
        {
            if (provider == null)
            {
                throw new ArgumentNullException(nameof(provider));
            }

            _provider = provider;
        }
Exemplo n.º 31
0
 /// <summary>
 /// DI constructor to supply all necessary services for razor engine to work
 /// </summary>
 /// <param name="viewEngine">view engine itself</param>
 /// <param name="tempDataProvider">temporary cross-request data storage provider</param>
 /// <param name="serviceProvider">service provider for other services as requested by the view</param>
 public RenderProjectFileCommand(
     IRazorViewEngine viewEngine,
     ITempDataProvider tempDataProvider,
     IServiceProvider serviceProvider)
 {
     _serviceProvider  = serviceProvider;
     _tempDataProvider = tempDataProvider;
     _viewEngine       = viewEngine;
 }
 public RazorViewRenderer(
     ICompositeViewEngine viewEngine,
     ITempDataProvider tempDataProvider,
     ILogger logger)
 {
     _viewEngine = viewEngine;
     _tempDataProvider = tempDataProvider;
     _logger = logger;
 }
Exemplo n.º 33
0
 public RazorViewToStringRenderer(
     IRazorViewEngine viewEngine,
     ITempDataProvider tempDataProvider,
     IServiceProvider serviceProvider)
 {
     this.viewEngine       = viewEngine;
     this.tempDataProvider = tempDataProvider;
     this.serviceProvider  = serviceProvider;
 }
 public RazorViewToString(
     IRazorViewEngine viewEngine,
     ITempDataProvider tempDataProvider,
     IServiceProvider serviceProvider)
 {
     _viewEngine       = viewEngine;
     _tempDataProvider = tempDataProvider;
     _serviceProvider  = serviceProvider;
 }
Exemplo n.º 35
0
 public RazorViewToStringRenderer(
     IRazorViewEngine viewEngine,
     ITempDataProvider tempDataProvider,
     IServiceProvider serviceProvider, IHttpContextAccessor contextAccessor, LinkGenerator linkGenerator)
 {
     _viewEngine       = viewEngine;
     _tempDataProvider = tempDataProvider;
     _serviceProvider  = serviceProvider;
 }
Exemplo n.º 36
0
 public InvoicesController(IProjectInvoicesManager invoiceManager,
     UserManager<AppUser> userManager,
     ICompositeViewEngine viewEngine,
     ITempDataProvider tempDataProvider,
     IHttpContextAccessor httpContextAccessor,
     IApplicationEnvironment hostingEnvironment,
     DatabaseContext dbContext)
 {
     _invoiceManager = invoiceManager;
     _viewEngine = viewEngine;
     _tempDataProvider = tempDataProvider;
     _httpContextAccessor = httpContextAccessor;
     _hostingEnvironment = hostingEnvironment;
     _dbContext = dbContext;
     _userManager = userManager;
 }
Exemplo n.º 37
0
 public ProjectInvoicesManager(DatabaseContext dbContext,
     ICompositeViewEngine viewEngine,
     ITempDataProvider tempDataProvider,
     IHttpContextAccessor httpContextAccessor,
     IApplicationEnvironment hostingEnvironment,
     IProjectWorkflowDefinitionFactory workflowDefinition,
     IProjectHistoryManager historyManager,
     IProjectAlertsManager alertsManager)
 {
     _dbContext = dbContext;
     _viewEngine = viewEngine;
     _tempDataProvider = tempDataProvider;
     _httpContextAccessor = httpContextAccessor;
     _hostingEnvironment = hostingEnvironment;
     _workflowDefinition = workflowDefinition;
     _historyManager = historyManager;
     _alertsManager = alertsManager;
 }
Exemplo n.º 38
0
 public WindsorControllerFactory(IKernel kernel)
 {
     this.kernel = kernel;
     dataProvider = new SessionlessTempDataProvider();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TempDataControllerFactory"/> class.
 /// </summary>
 /// <param name="controllerFactory">
 /// The controller factory.
 /// </param>
 /// <param name="tempDataProvider">
 /// The temp Data Provider.
 /// </param>
 public TempDataControllerFactory(IControllerFactory controllerFactory, ITempDataProvider tempDataProvider)
 {
     this.controllerFactory = controllerFactory;
     this.tempDataProvider = tempDataProvider;
 }