Ejemplo n.º 1
0
        public IEnumerable <ClientRouteDescriptor> GetRouteTable(bool isFrontEnd)
        {
            Logger.Information("Start building shape table");

            var alterationSets = _parallelCacheContext.RunInParallel(
                _clientRouteProviders.Where(provider => provider.Value.IsFrontEnd == isFrontEnd), provider => {
                var feature = provider.Metadata.ContainsKey("Feature") ?
                              (Feature)provider.Metadata["Feature"] :
                              null;

                var builder = new ClientRouteTableBuilder(feature);
                provider.Value.Discover(builder);
                return(builder.BuildAlterations().ToReadOnlyCollection());
            });

            var alterations = alterationSets
                              .SelectMany(shapeAlterations => shapeAlterations)
                              .ToList();
            var distinctRouteNames = alterations.GroupBy(item => item.RouteName, StringComparer.OrdinalIgnoreCase)
                                     .Select(item => item.Key).ToList();

            var routes = GenerateRoutes(distinctRouteNames, alterations);

            Logger.Information("Done building shape table");
            return(routes);
        }
        public object GetRouteTable(bool isFrontEnd) {

            //return _cacheManager.Get<string, object>("ClientRouteTable", x => {
                Logger.Information("Start building shape table");

            var alterationSets = _parallelCacheContext.RunInParallel(
                _clientRouteProviders.Where(provider => provider.Value.IsFrontEnd == isFrontEnd), provider => {
                    var feature = provider.Metadata.ContainsKey("Feature") ?
                                      (Feature) provider.Metadata["Feature"] :
                                      null;

                    var builder = new ClientRouteTableBuilder(feature);
                    provider.Value.Discover(builder);
                    return builder.BuildAlterations().ToReadOnlyCollection();
                });

                var alterations = alterationSets
                    .SelectMany(shapeAlterations => shapeAlterations)
                    .ToList();

                var routeNodes = alterations.GroupBy(alteration => alteration.RouteName, StringComparer.OrdinalIgnoreCase)
                                            .Select(group => new ClientRouteNode {Name = GetRouteName(group.Key), FullName = group.Key})
                                            .ToList();

                var rootNodes = routeNodes.Where(node => !node.FullName.Contains("."));
                PopulateChildren(routeNodes);

                var routes = GenerateRoutes(rootNodes, alterations);

                Logger.Information("Done building shape table");
                return routes;
            //});
        }
        public IEnumerable<ClientRouteDescriptor> GetRouteTable(bool isFrontEnd) {
            Logger.Information("Start building shape table");

            var alterationSets = _parallelCacheContext.RunInParallel(
                _clientRouteProviders.Where(provider => provider.Value.IsFrontEnd == isFrontEnd), provider => {
                    var feature = provider.Metadata.ContainsKey("Feature") ?
                        (Feature) provider.Metadata["Feature"] :
                        null;

                    var builder = new ClientRouteTableBuilder(feature);
                    provider.Value.Discover(builder);
                    return builder.BuildAlterations().ToReadOnlyCollection();
                });

            var alterations = alterationSets
                .SelectMany(shapeAlterations => shapeAlterations)
                .ToList();
            var distinctRouteNames = alterations.GroupBy(item => item.RouteName, StringComparer.OrdinalIgnoreCase)
                .Select(item => item.Key).ToList();

            var routes = GenerateRoutes(distinctRouteNames, alterations);
            Logger.Information("Done building shape table");
            return routes;
        }