public EsiMiddleware( RequestDelegate next, EsiBodyParser parser, EsiFragmentExecutor executor, EsiFragmentCacheFacade cache) { _next = next ?? throw new ArgumentNullException(nameof(next)); _parser = parser ?? throw new ArgumentNullException(nameof(parser)); _executor = executor ?? throw new ArgumentNullException(nameof(executor)); _cache = cache ?? throw new ArgumentNullException(nameof(cache)); }
public static EsiFragmentExecutor Create( EsiFragmentCacheFacade cache, IHttpLoader httpLoader, EsiBodyParser parser, Log log, ServiceFactory serviceFactory, IncludeUriParser includeUriParser) { if (cache == null) { throw new ArgumentNullException(nameof(cache)); } if (httpLoader == null) { throw new ArgumentNullException(nameof(httpLoader)); } if (parser == null) { throw new ArgumentNullException(nameof(parser)); } if (log == null) { throw new ArgumentNullException(nameof(log)); } if (serviceFactory == null) { throw new ArgumentNullException(nameof(serviceFactory)); } if (includeUriParser == null) { throw new ArgumentNullException(nameof(includeUriParser)); } var executors = new Dictionary <Type, Func <IEsiFragment, EsiExecutionContext, Task <IEnumerable <string> > > >(); var fragmentExecutor = new EsiFragmentExecutor(executors, serviceFactory); var includeExecutor = new EsiIncludeFragmentExecutor(includeUriParser, cache, httpLoader, parser, fragmentExecutor); var ignoreExecutor = new EsiIgnoreFragmentExecutor(); var textExecutor = new EsiTextFragmentExecutor(); var compositeExecutor = new EsiCompositeFragmentExecutor(fragmentExecutor); var tryExecutor = new EsiTryFragmentExecutor(fragmentExecutor, log); var chooseExecutor = new EsiChooseFragmentExecutor(fragmentExecutor); var varsExecutor = new EsiVarsFragmentExecutor(); executors[typeof(EsiIncludeFragment)] = (f, ec) => includeExecutor.Execute((EsiIncludeFragment)f, ec); executors[typeof(EsiIgnoreFragment)] = (f, ec) => ignoreExecutor.Execute((EsiIgnoreFragment)f, ec); executors[typeof(EsiTextFragment)] = (f, ec) => textExecutor.Execute((EsiTextFragment)f, ec); executors[typeof(EsiCompositeFragment)] = (f, ec) => compositeExecutor.Execute((EsiCompositeFragment)f, ec); executors[typeof(EsiTryFragment)] = (f, ec) => tryExecutor.Execute((EsiTryFragment)f, ec); executors[typeof(EsiChooseFragment)] = (f, ec) => chooseExecutor.Execute((EsiChooseFragment)f, ec); executors[typeof(EsiVarsFragment)] = (f, ec) => varsExecutor.Execute((EsiVarsFragment)f, ec); return(fragmentExecutor); }
public EsiIncludeFragmentExecutor( IncludeUriParser uriParser, EsiFragmentCacheFacade cache, IHttpLoader httpLoader, EsiBodyParser esiBodyParser, EsiFragmentExecutor fragmentExecutor) { _uriParser = uriParser ?? throw new ArgumentNullException(nameof(uriParser)); _cache = cache ?? throw new ArgumentNullException(nameof(cache)); _httpLoader = httpLoader ?? throw new ArgumentNullException(nameof(httpLoader)); _esiBodyParser = esiBodyParser ?? throw new ArgumentNullException(nameof(esiBodyParser)); _fragmentExecutor = fragmentExecutor ?? throw new ArgumentNullException(nameof(fragmentExecutor)); }
public static EsiBodyParser Create( IEnumerable <IFragmentParsePipeline> parsePipelines) { if (parsePipelines == null) { throw new ArgumentNullException(nameof(parsePipelines)); } var parsers = new Dictionary <string, IEsiFragmentParser>(); var fragmentParser = new EsiFragmentParser(parsers, parsePipelines); var bodyParser = new EsiBodyParser(fragmentParser); parsers["esi:include"] = new EsiIncludeParser(); parsers["esi:remove"] = new EsiIgnoreParser(); parsers["esi:comment"] = new EsiIgnoreParser(); parsers["esi:text"] = new EsiTextParser(); parsers["esi:try"] = new EsiTryParser(bodyParser); parsers["esi:choose"] = new EsiChooseParser(bodyParser); parsers["esi:vars"] = new EsiVarsParser(); return(bodyParser); }
public EsiTryParser(EsiBodyParser bodyParser) { _bodyParser = bodyParser ?? throw new ArgumentNullException(nameof(bodyParser)); }