Example #1
0
        private Matcher CreateDfaMatcher(
            EndpointDataSource dataSource,
            MatcherPolicy[] policies          = null,
            EndpointSelector endpointSelector = null,
            ILoggerFactory loggerFactory      = null)
        {
            var serviceCollection = new ServiceCollection()
                                    .AddLogging()
                                    .AddOptions()
                                    .AddRouting();

            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)));
        }
Example #2
0
            public SelectorRouter(EndpointSelector selector, MatcherEndpoint[] candidates)
            {
                _selector   = selector;
                _candidates = candidates;

                _scores = new int[_candidates.Length];
            }
Example #3
0
 public DfaMatcher(ILogger <DfaMatcher> logger, EndpointSelector selector, DfaState[] states, int maxSegmentCount)
 {
     _logger          = logger;
     _selector        = selector;
     _states          = states;
     _maxSegmentCount = maxSegmentCount;
 }
            public SelectorRouter(EndpointSelector selector, RouteEndpoint[] candidates)
            {
                _selector   = selector;
                _candidates = candidates;

                _values = new RouteValueDictionary[_candidates.Length];
                _scores = new int[_candidates.Length];
            }
Example #5
0
        public DfaMatcherBuilder(
            MatchProcessorFactory matchProcessorFactory,
            EndpointSelector selector,
            IEnumerable <MatcherPolicy> policies)
        {
            _matchProcessorFactory = matchProcessorFactory;
            _selector = selector;
            _policies = policies.OrderBy(p => p.Order).ToArray();

            // Taking care to use _policies, which has been sorted.
            _nodeBuilders = _policies.OfType <INodeBuilderPolicy>().ToArray();
            _comparer     = new MatcherEndpointComparer(_policies.OfType <IEndpointComparerPolicy>().ToArray());
        }
Example #6
0
        private Matcher CreateDfaMatcher(EndpointDataSource dataSource, EndpointSelector endpointSelector = null)
        {
            var serviceCollection = new ServiceCollection()
                                    .AddLogging()
                                    .AddOptions()
                                    .AddRouting();

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

            var services = serviceCollection.BuildServiceProvider();

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

            return(Assert.IsType <DataSourceDependentMatcher>(factory.CreateMatcher(dataSource)));
        }
Example #7
0
 public DfaMatcher(EndpointSelector selector, DfaState[] states, int maxSegmentCount)
 {
     _selector        = selector;
     _states          = states;
     _maxSegmentCount = maxSegmentCount;
 }
Example #8
0
 public DfaMatcher(EndpointSelector selector, DfaState[] states)
 {
     _selector = selector;
     _states   = states;
 }