private ConcurrentDictionary <string, RouteEntry> InitializeTable() { var routeEntries = from component in _commandComponents let componentType = component.GetType() where componentType.Name.EndsWith("Command") from routePath in _routeHandler.Handle(componentType) select new RouteEntry { RoutePath = routePath, RequestType = componentType, HandlerType = typeof(ICommandHandler <>).MakeGenericType(componentType) }; return(new ConcurrentDictionary <string, RouteEntry>( routeEntries.ToDictionary(routeEntry => routeEntry.RoutePath, routeEntry => routeEntry) )); }
private ConcurrentDictionary <string, RouteEntry> InitializeTable() { var routeEntries = from component in _queryComponents let componentType = component.GetType() where componentType.Name.EndsWith("Query") let serviceType = componentType.GetInterfaces().Single( i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IQuery <>) ) let resultType = serviceType.GenericTypeArguments[0] let handlerType = typeof(IQueryHandler <,>).MakeGenericType(componentType, resultType) from routePath in _routeHandler.Handle(componentType) select new RouteEntry { RoutePath = routePath, RequestType = componentType, HandlerType = handlerType }; return(new ConcurrentDictionary <string, RouteEntry>( routeEntries.ToDictionary(routeEntry => routeEntry.RoutePath, routeEntry => routeEntry) )); }