private static void read_microservices_simple_endpoint_details(XmlReader ReaderXml, List<Microservice_Endpoint> AllEndpoints, Dictionary<Microservice_VerbMapping, string> EndpointToComponentDictionary, Dictionary<Microservice_VerbMapping, string> EndpointToRestrictionDictionary, Microservice_Path ParentSegment)
        {
            Microservice_Endpoint endpoint = new Microservice_Endpoint();
            string componentid = String.Empty;
            string restrictionid = String.Empty;
            string method = String.Empty;
            bool enabled = true;
            Microservice_Endpoint_Protocol_Enum protocol = Microservice_Endpoint_Protocol_Enum.JSON;

            if (ReaderXml.MoveToAttribute("Segment"))
                endpoint.Segment = ReaderXml.Value.Trim();
            if (ReaderXml.MoveToAttribute("ComponentID"))
                componentid = ReaderXml.Value.Trim();
            if (ReaderXml.MoveToAttribute("Method"))
                method = ReaderXml.Value.Trim();
            if (ReaderXml.MoveToAttribute("Enabled"))
            {
                if (String.Compare(ReaderXml.Value.Trim(), "false", StringComparison.OrdinalIgnoreCase) == 0)
                    enabled = false;
            }
            if (ReaderXml.MoveToAttribute("RestrictionRangeID"))
                restrictionid = ReaderXml.Value.Trim();
            if (ReaderXml.MoveToAttribute("Protocol"))
            {
                switch (ReaderXml.Value.Trim().ToUpper())
                {
                    case "JSON":
                        protocol = Microservice_Endpoint_Protocol_Enum.JSON;
                        break;

                    case "JSON-P":
                        protocol = Microservice_Endpoint_Protocol_Enum.JSON_P;
                        break;

                    case "PROTOBUF":
                        protocol = Microservice_Endpoint_Protocol_Enum.PROTOBUF;
                        break;

                    case "SOAP":
                        protocol = Microservice_Endpoint_Protocol_Enum.SOAP;
                        break;

                    case "XML":
                        protocol = Microservice_Endpoint_Protocol_Enum.XML;
                        break;

                    default:
                        protocol = Microservice_Endpoint_Protocol_Enum.JSON;
                        break;
                }
            }

            ReaderXml.MoveToElement();

            if ((componentid.Length > 0) && (endpoint.Segment.Length > 0) && (method.Length > 0))
            {
                if (ParentSegment != null)
                {
                    // Add this endpoint
                    if (ParentSegment.Children == null)
                        ParentSegment.Children = new Dictionary<string, Microservice_Path>();
                    ParentSegment.Children[endpoint.Segment] = endpoint;
                    AllEndpoints.Add(endpoint);

                    // Add the verb mapping defaulted to GET
                    endpoint.GetMapping = new Microservice_VerbMapping(method, enabled, protocol, Microservice_Endpoint_RequestType_Enum.GET);
                    EndpointToComponentDictionary[endpoint.GetMapping] = componentid;
                    EndpointToRestrictionDictionary[endpoint.GetMapping] = restrictionid;
                }
            }
        }
        private static void read_microservices_details_mapping(XmlReader ReaderXml, Microservice_Server_Configuration Config, List<Microservice_Endpoint> AllEndpoints, Dictionary<Microservice_VerbMapping, string> EndpointToComponentDictionary, Dictionary<Microservice_VerbMapping, string> EndpointToRestrictionDictionary, Microservice_Path ParentSegment)
        {
            while (ReaderXml.Read())
            {
                if (ReaderXml.NodeType == XmlNodeType.Element)
                {
                    switch (ReaderXml.Name.ToLower())
                    {
                        case "removeall":
                            if (ParentSegment != null)
                            {
                                if ( ParentSegment.Children != null )
                                    ParentSegment.Children.Clear();
                            }
                            else
                            {
                                Config.RootPaths.Clear();
                            }
                            break;

                        case "path":
                            if (ReaderXml.MoveToAttribute("Segment"))
                            {
                                Microservice_Path path;
                                string segment = ReaderXml.Value.Trim();

                                if (ParentSegment == null)
                                {
                                    if (Config.RootPaths.ContainsKey(segment.ToLower()))
                                        path = Config.RootPaths[segment.ToLower()];
                                    else
                                    {
                                        path = new Microservice_Path { Segment = segment };
                                        Config.RootPaths[segment.ToLower()] = path;
                                    }
                                }
                                else
                                {
                                    if (ParentSegment.Children == null)
                                        ParentSegment.Children = new Dictionary<string, Microservice_Path>(StringComparer.OrdinalIgnoreCase);

                                    if (ParentSegment.Children.ContainsKey(segment.ToLower()))
                                    {
                                        path = ParentSegment.Children[segment.ToLower()];
                                    }
                                    else
                                    {
                                        path = new Microservice_Path {Segment = segment};
                                        ParentSegment.Children[path.Segment] = path;
                                    }

                                }

                                ReaderXml.MoveToElement();
                                XmlReader subTreeReader = ReaderXml.ReadSubtree();
                                subTreeReader.Read();
                                read_microservices_details_mapping(subTreeReader, Config, AllEndpoints, EndpointToComponentDictionary, EndpointToRestrictionDictionary, path);
                            }
                            break;

                        case "complexendpoint":

                            // Read the top-endpoint information, before getting to each verb mapping
                            bool disabled_at_top = false;
                            Microservice_Endpoint endpoint = new Microservice_Endpoint();
                            if (ReaderXml.MoveToAttribute("Segment"))
                                endpoint.Segment = ReaderXml.Value.Trim();
                            if ((ReaderXml.MoveToAttribute("Enabled")) && (String.Compare(ReaderXml.Value.Trim(), "false", StringComparison.OrdinalIgnoreCase) == 0))
                                disabled_at_top = true;

                            // Now, read what remains
                            ReaderXml.MoveToElement();
                            XmlReader complexReader = ReaderXml.ReadSubtree();
                            complexReader.Read();
                            read_microservices_complex_endpoint_details(complexReader, EndpointToComponentDictionary, EndpointToRestrictionDictionary, endpoint, disabled_at_top );

                            // If a verb was mapped and there was a valid segment, add this
                            if ((!String.IsNullOrEmpty(endpoint.Segment)) && (endpoint.HasVerbMapping))
                            {
                                if (ParentSegment != null)
                                {
                                    // Add this endpoint
                                    if (ParentSegment.Children == null)
                                        ParentSegment.Children = new Dictionary<string, Microservice_Path>();
                                    ParentSegment.Children[endpoint.Segment] = endpoint;
                                    AllEndpoints.Add(endpoint);
                                }
                            }
                            break;

                        case "endpoint":
                            read_microservices_simple_endpoint_details(ReaderXml, AllEndpoints, EndpointToComponentDictionary, EndpointToRestrictionDictionary, ParentSegment);
                            break;
                    }
                }
            }
        }