Пример #1
0
        public static EdgeHubConfig GetEdgeHubConfig(EdgeHubDesiredProperties desiredProperties, RouteFactory routeFactory)
        {
            Preconditions.CheckNotNull(desiredProperties, nameof(desiredProperties));

            ValidateSchemaVersion(desiredProperties.SchemaVersion);

            var routes = new Dictionary <string, RouteConfig>();

            if (desiredProperties.Routes != null)
            {
                foreach (KeyValuePair <string, RouteConfiguration> inputRoute in desiredProperties.Routes)
                {
                    try
                    {
                        Route route = routeFactory.Create(inputRoute.Value.Route, inputRoute.Value.Priority, inputRoute.Value.TimeToLiveSecs);
                        routes.Add(inputRoute.Key, new RouteConfig(inputRoute.Key, inputRoute.Value.Route, route));
                    }
                    catch (Exception ex)
                    {
                        throw new InvalidOperationException($"Error parsing route {inputRoute.Key} - {ex.Message}", ex);
                    }
                }
            }

            return(new EdgeHubConfig(desiredProperties.SchemaVersion, new ReadOnlyDictionary <string, RouteConfig>(routes), desiredProperties.StoreAndForwardConfiguration));
        }
Пример #2
0
        public EdgeHubConfig GetEdgeHubConfig(EdgeHubDesiredProperties desiredProperties)
        {
            Preconditions.CheckNotNull(desiredProperties, nameof(desiredProperties));

            ReadOnlyDictionary <string, RouteConfig> routes = ParseRoutes(desiredProperties, this.routeFactory);

            Option <BrokerConfig> brokerConfig = this.ParseBrokerConfig(desiredProperties.BrokerConfiguration);

            return(new EdgeHubConfig(
                       desiredProperties.SchemaVersion,
                       routes,
                       desiredProperties.StoreAndForwardConfiguration,
                       brokerConfig));
        }
Пример #3
0
        static ReadOnlyDictionary <string, RouteConfig> ParseRoutes(EdgeHubDesiredProperties desiredProperties, RouteFactory routeFactory)
        {
            var routes = new Dictionary <string, RouteConfig>();

            if (desiredProperties.Routes != null)
            {
                foreach (KeyValuePair <string, RouteConfiguration> inputRoute in desiredProperties.Routes)
                {
                    try
                    {
                        Route route = routeFactory.Create(inputRoute.Value.Route, inputRoute.Value.Priority, inputRoute.Value.TimeToLiveSecs);
                        routes.Add(inputRoute.Key, new RouteConfig(inputRoute.Key, inputRoute.Value.Route, route));
                    }
                    catch (Exception ex)
                    {
                        throw new InvalidOperationException($"Error parsing route {inputRoute.Key} - {ex.Message}", ex);
                    }
                }
            }

            return(new ReadOnlyDictionary <string, RouteConfig>(routes));
        }