Source/Routing/MqttRouteTableFactory.cs
/// <summary>
/// Generate routes given a collection of MethodInfo objects and templates that should call those methods
/// </summary>
/// <param name="templatesByHandler">Templates that should route to each handler</param>
Generate routes given a collection of MethodInfo objects and templates that should call those methods
Generate routes given a collection of MethodInfo objects and templates that should call those methods
internal static MqttRouteTable Create(Dictionary<MethodInfo, string[]> templatesByHandler)
        {
            var routes = new List<MqttRoute>();
            foreach (var keyValuePair in templatesByHandler)
            {
                var parsedTemplates = keyValuePair.Value.Select(v => TemplateParser.ParseTemplate(v)).ToArray();
                var allRouteParameterNames = parsedTemplates
                    .SelectMany(GetParameterNames)
                    .Distinct(StringComparer.OrdinalIgnoreCase)
                    .ToArray();
                foreach (var parsedTemplate in parsedTemplates)
                {
                    var unusedRouteParameterNames = allRouteParameterNames
                        .Except(GetParameterNames(parsedTemplate), StringComparer.OrdinalIgnoreCase)
                        .ToArray();
                    var entry = new MqttRoute(parsedTemplate, keyValuePair.Key, unusedRouteParameterNames);
                    routes.Add(entry);
                }
            }
            return new MqttRouteTable(routes.OrderBy(id => id, RoutePrecedence).ToArray());
        }
internal static MqttRouteTable Create ( Dictionary < MethodInfo , string [ ] > templatesByHandler ) { var routes = new List < MqttRoute > ( ) ; foreach ( var keyValuePair in templatesByHandler ) { var parsedTemplates = keyValuePair . Value . Select ( v => TemplateParser . ParseTemplate ( v ) ) . ToArray ( ) ; var allRouteParameterNames = parsedTemplates . SelectMany ( GetParameterNames ) . Distinct ( StringComparer . OrdinalIgnoreCase ) . ToArray ( ) ; foreach ( var parsedTemplate in parsedTemplates ) { var unusedRouteParameterNames = allRouteParameterNames . Except ( GetParameterNames ( parsedTemplate ) , StringComparer . OrdinalIgnoreCase ) . ToArray ( ) ; var entry = new MqttRoute ( parsedTemplate , keyValuePair . Key , unusedRouteParameterNames ) ; routes . Add ( entry ) ; } } return new MqttRouteTable ( routes . OrderBy ( id => id , RoutePrecedence ) . ToArray ( ) ) ; }
Generate routes given a collection of MethodInfo objects and templates that should call those methods
Generate routes given a collection of MethodInfo objects and templates that should call those methods
templatesByHandler
Dictionary<MethodInfo, string[]>
Templates that should route to each handler
Templates that should route to each handler