public DefaultLinkGenerator( ParameterPolicyFactory parameterPolicyFactory, GlobalRouteValuesLinkGeneratorTemplateBinderFactory binderFactory, EndpointDataSource dataSource, IOptions <RouteOptions> routeOptions, ILogger <DefaultLinkGenerator> logger, IServiceProvider serviceProvider) { _parameterPolicyFactory = parameterPolicyFactory; _binderFactory = binderFactory; _logger = logger; _serviceProvider = serviceProvider; // We cache GlobalRouteValuesLinkGeneratorTemplateBinder instances per-Endpoint for performance, but we want to wipe out // that cache is the endpoints change so that we don't allow unbounded memory growth. _cache = new DataSourceDependentCache <ConcurrentDictionary <RouteEndpoint, GlobalRouteValuesLinkGeneratorTemplateBinder> >(dataSource, (_) => { // We don't eagerly fill this cache because there's no real reason to. Unlike URL matching, we don't // need to build a big data structure up front to be correct. return(new ConcurrentDictionary <RouteEndpoint, GlobalRouteValuesLinkGeneratorTemplateBinder>()); }); // Cached to avoid per-call allocation of a delegate on lookup. _createTemplateBinder = CreateTemplateBinder; _globalLinkOptions = new LinkOptions() { AppendTrailingSlash = routeOptions.Value.AppendTrailingSlash, LowercaseQueryStrings = routeOptions.Value.LowercaseQueryStrings, LowercaseUrls = routeOptions.Value.LowercaseUrls, }; }
public GlobalRouteValuesLinkGenerator( ParameterPolicyFactory parameterPolicyFactory, GlobalRouteValuesLinkGeneratorTemplateBinderFactory binderFactory, EndpointDataSource dataSource, IOptions <RouteOptions> routeOptions, ILogger <DefaultLinkGenerator> logger, IServiceProvider serviceProvider, IOptions <GlobalRouteValuesLinkGeneratorOptions> options) : base(parameterPolicyFactory, binderFactory, dataSource, routeOptions, logger, serviceProvider) { _globalRouteKeys = options.Value.GlobalRouteKeys ?? Array.Empty <string>(); }