Exemplo n.º 1
0
 public DfaMatcher(ILogger <DfaMatcher> logger, EndpointSelector selector, DfaState[] states, int maxSegmentCount)
 {
     _logger          = logger;
     _selector        = selector;
     _states          = states;
     _maxSegmentCount = maxSegmentCount;
 }
Exemplo n.º 2
0
            public SelectorRouter(EndpointSelector selector, RouteEndpoint[] candidates)
            {
                _selector   = selector;
                _candidates = candidates;

                _values = new RouteValueDictionary[_candidates.Length];
                _scores = new int[_candidates.Length];
            }
Exemplo n.º 3
0
        private Matcher CreateDfaMatcher(
            EndpointDataSource dataSource,
            MatcherPolicy[] policies          = null,
            EndpointSelector endpointSelector = null,
            ILoggerFactory loggerFactory      = null)
        {
            var serviceCollection = new ServiceCollection()
                                    .AddLogging()
                                    .AddOptions()
                                    .AddRouting(options =>
            {
                options.ConstraintMap["slugify"] = typeof(SlugifyParameterTransformer);
            });

            if (policies != null)
            {
                for (var i = 0; i < policies.Length; i++)
                {
                    serviceCollection.AddSingleton <MatcherPolicy>(policies[i]);
                }
            }

            if (endpointSelector != null)
            {
                serviceCollection.AddSingleton <EndpointSelector>(endpointSelector);
            }

            if (loggerFactory != null)
            {
                serviceCollection.AddSingleton <ILoggerFactory>(loggerFactory);
            }

            var services = serviceCollection.BuildServiceProvider();

            var factory = services.GetRequiredService <MatcherFactory>();

            return(Assert.IsType <DataSourceDependentMatcher>(factory.CreateMatcher(dataSource)));
        }