mirror of https://github.com/abpframework/abp.git
csharpabpc-sharpframeworkblazoraspnet-coredotnet-coreaspnetcorearchitecturesaasdomain-driven-designangularmulti-tenancy
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
1.1 KiB
33 lines
1.1 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Options;
|
|
using Volo.Abp.DependencyInjection;
|
|
|
|
namespace Volo.Docs.HtmlConverting
|
|
{
|
|
public class DocumentToHtmlConverterFactory : IDocumentToHtmlConverterFactory, ITransientDependency
|
|
{
|
|
protected DocumentToHtmlConverterOptions Options { get; }
|
|
protected IServiceProvider ServiceProvider { get; }
|
|
|
|
public DocumentToHtmlConverterFactory(
|
|
IServiceProvider serviceProvider,
|
|
IOptions<DocumentToHtmlConverterOptions> options)
|
|
{
|
|
ServiceProvider = serviceProvider;
|
|
Options = options.Value;
|
|
}
|
|
|
|
public virtual IDocumentToHtmlConverter Create(string format)
|
|
{
|
|
var serviceType = Options.Converters.GetOrDefault(format);
|
|
if (serviceType == null)
|
|
{
|
|
throw new ApplicationException($"Unknown document format: {format}");
|
|
}
|
|
|
|
return (IDocumentToHtmlConverter)ServiceProvider.GetRequiredService(serviceType);
|
|
}
|
|
}
|
|
}
|